diff --git a/src/General/Get.coffee b/src/General/Get.coffee index 9dffdf722..90f41bdd8 100755 --- a/src/General/Get.coffee +++ b/src/General/Get.coffee @@ -13,7 +13,7 @@ Get = Get.threadFromRoot $.x 'ancestor::div[@class="thread"]', node postFromRoot: (root) -> link = $ '.postNum > a[href*="#"]', root - boardID = link.pathname.split('/')[1] + boardID = link.pathname.split(/\/+/)[1] postID = link.hash[2..] index = root.dataset.clone post = g.posts["#{boardID}.#{postID}"] @@ -24,7 +24,7 @@ Get = Get.postFromRoot $.x 'ancestor::div[parent::div[@class="thread"]][1]', node postDataFromLink: (link) -> if link.hostname is 'boards.4chan.org' - path = link.pathname.split '/' + path = link.pathname.split /\/+/ boardID = path[1] threadID = path[3] postID = link.hash[2..] diff --git a/src/General/lib/post.class b/src/General/lib/post.class index 039999b55..97f84fa6a 100755 --- a/src/General/lib/post.class +++ b/src/General/lib/post.class @@ -162,9 +162,9 @@ class Post # - rules links. (>>>/a/rules) # - text-board quotelinks. (>>>/img/1234) return unless match = quotelink.href.match /// - boards\.4chan\.org/ + ^https?://boards\.4chan\.org/+ ([^/]+) # boardID - /(?:res|thread)/\d+(?:\/[^#]*)?#p + /+(?:res|thread)/+\d+(?:/[^#]*)?#p (\d+) # postID $ /// diff --git a/src/Miscellaneous/CatalogLinks.coffee b/src/Miscellaneous/CatalogLinks.coffee index 2ba5aa4e3..6956514a6 100755 --- a/src/Miscellaneous/CatalogLinks.coffee +++ b/src/Miscellaneous/CatalogLinks.coffee @@ -7,7 +7,7 @@ CatalogLinks = when 'index' then '#ctrl-top > a, .cataloglink > a' $.ready -> for link in $$ selector - switch link.pathname + switch link.pathname.replace /\/+/g, '/' when "/#{g.BOARD}/" link.textContent = 'Index' if Conf['JSON Navigation'] link.href = CatalogLinks.index() diff --git a/src/Miscellaneous/ExpandComment.coffee b/src/Miscellaneous/ExpandComment.coffee index 9e6822b96..b179132a8 100755 --- a/src/Miscellaneous/ExpandComment.coffee +++ b/src/Miscellaneous/ExpandComment.coffee @@ -26,7 +26,7 @@ ExpandComment = return return unless a = $ '.abbr > a', post.nodes.comment a.textContent = "Post No.#{post} Loading..." - $.cache "//a.4cdn.org#{a.pathname.split('/').splice(0,4).join('/')}.json", -> ExpandComment.parse @, a, post + $.cache "//a.4cdn.org#{a.pathname.split(/\/+/).splice(0,4).join('/')}.json", -> ExpandComment.parse @, a, post contract: (post) -> return unless post.nodes.shortComment @@ -59,9 +59,9 @@ ExpandComment = href = quote.getAttribute 'href' continue if href[0] is '/' # Cross-board quote, or board link if href[0] is '#' - quote.href = "#{a.pathname.split('/').splice(0,4).join('/')}#{href}" + quote.href = "#{a.pathname.split(/\/+/).splice(0,4).join('/')}#{href}" else - quote.href = "#{a.pathname.split('/').splice(0,3).join('/')}/#{href}" + quote.href = "#{a.pathname.split(/\/+/).splice(0,3).join('/')}/#{href}" post.nodes.shortComment = comment $.replace comment, clone post.nodes.comment = post.nodes.longComment = clone