Make 4chan X tolerant of redundant slashes in 4chan URLs. #499
This commit is contained in:
parent
29a35817d3
commit
2379b0f31d
@ -263,7 +263,7 @@ Index =
|
|||||||
return
|
return
|
||||||
return if a.textContent is 'Catalog'
|
return if a.textContent is 'Catalog'
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
Index.userPageNav +a.pathname.split('/')[2] or 1
|
Index.userPageNav +a.pathname.split(/\/+/)[2] or 1
|
||||||
|
|
||||||
refreshFront: ->
|
refreshFront: ->
|
||||||
Index.update Index.pushState {page: 1, scroll: true}
|
Index.update Index.pushState {page: 1, scroll: true}
|
||||||
@ -275,7 +275,7 @@ Index =
|
|||||||
if Conf['Index Mode'] in ['all pages', 'catalog']
|
if Conf['Index Mode'] in ['all pages', 'catalog']
|
||||||
1
|
1
|
||||||
else
|
else
|
||||||
+window.location.pathname.split('/')[2] or 1
|
+window.location.pathname.split(/\/+/)[2] or 1
|
||||||
|
|
||||||
userPageNav: (page) ->
|
userPageNav: (page) ->
|
||||||
state = Index.pushState {page, scroll: true}
|
state = Index.pushState {page, scroll: true}
|
||||||
@ -323,7 +323,7 @@ Index =
|
|||||||
mode: Conf['Index Mode']
|
mode: Conf['Index Mode']
|
||||||
searched: Index.search
|
searched: Index.search
|
||||||
oldpage: pageBeforeSearch
|
oldpage: pageBeforeSearch
|
||||||
, '', pathname + hash
|
, '', "#{location.protocol}//#{location.host}#{pathname}#{hash}"
|
||||||
state
|
state
|
||||||
|
|
||||||
saveMode: (mode) ->
|
saveMode: (mode) ->
|
||||||
|
|||||||
@ -21,7 +21,7 @@ Main =
|
|||||||
g.threads = new SimpleDict()
|
g.threads = new SimpleDict()
|
||||||
g.posts = new SimpleDict()
|
g.posts = new SimpleDict()
|
||||||
|
|
||||||
pathname = location.pathname.split '/'
|
pathname = location.pathname.split /\/+/
|
||||||
g.BOARD = new Board pathname[1]
|
g.BOARD = new Board pathname[1]
|
||||||
return if g.BOARD.ID in ['z', 'fk']
|
return if g.BOARD.ID in ['z', 'fk']
|
||||||
g.VIEW =
|
g.VIEW =
|
||||||
@ -119,7 +119,7 @@ Main =
|
|||||||
when 'i.4cdn.org'
|
when 'i.4cdn.org'
|
||||||
$.asap (-> d.readyState isnt 'loading'), ->
|
$.asap (-> d.readyState isnt 'loading'), ->
|
||||||
if Conf['404 Redirect'] and d.title in ['4chan - Temporarily Offline', '4chan - 404 Not Found']
|
if Conf['404 Redirect'] and d.title in ['4chan - Temporarily Offline', '4chan - 404 Not Found']
|
||||||
pathname = location.pathname.split '/'
|
pathname = location.pathname.split /\/+/
|
||||||
Redirect.navigate 'file',
|
Redirect.navigate 'file',
|
||||||
boardID: g.BOARD.ID
|
boardID: g.BOARD.ID
|
||||||
filename: pathname[pathname.length - 1]
|
filename: pathname[pathname.length - 1]
|
||||||
@ -134,10 +134,10 @@ Main =
|
|||||||
return
|
return
|
||||||
|
|
||||||
if Conf['Normalize URL'] and g.VIEW is 'thread'
|
if Conf['Normalize URL'] and g.VIEW is 'thread'
|
||||||
pathname = location.pathname.split '/'
|
pathname = location.pathname.split /\/+/
|
||||||
if pathname[2] isnt 'thread' or pathname.length > 4
|
if pathname[2] isnt 'thread' or pathname.length > 4
|
||||||
pathname[2] = 'thread'
|
pathname[2] = 'thread'
|
||||||
history.replaceState null, '', pathname[0...4].join('/') + location.hash
|
history.replaceState null, '', "#{location.protocol}//#{location.host}#{pathname[0...4].join('/')}#{location.hash}"
|
||||||
|
|
||||||
# c.time 'All initializations'
|
# c.time 'All initializations'
|
||||||
for [name, feature] in Main.features
|
for [name, feature] in Main.features
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user