Make 4chan X tolerant of redundant slashes in 4chan URLs, part 2. #499
Stuff I missed in 2379b0f31da60a03f0dd9e0350b8dde3d3fe64e8.
This commit is contained in:
parent
6a24c53ce0
commit
972a40b572
@ -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..]
|
||||
|
||||
@ -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
|
||||
$
|
||||
///
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user