Move 'Normalize URL' out of Main.coffee to feature list.
This commit is contained in:
parent
5dc7b985ad
commit
d7268d2518
@ -130,17 +130,6 @@ Main =
|
||||
# set up CSS when <head> is completely loaded
|
||||
$.onExists doc, 'body', false, Main.initStyle
|
||||
|
||||
if Conf['Normalize URL']
|
||||
switch g.VIEW
|
||||
when 'thread'
|
||||
pathname[2] = 'thread'
|
||||
pathname = pathname[0...4]
|
||||
when 'index'
|
||||
pathname = pathname[0...3]
|
||||
pathname2 = pathname.join '/'
|
||||
if location.pathname isnt pathname2
|
||||
history.replaceState history.state, '', "#{location.protocol}//#{location.host}#{pathname2}#{location.hash}"
|
||||
|
||||
# c.time 'All initializations'
|
||||
for [name, feature] in Main.features
|
||||
# c.time "#{name} initialization"
|
||||
@ -366,6 +355,7 @@ Main =
|
||||
|
||||
features: [
|
||||
['Polyfill', Polyfill]
|
||||
['Normalize URL', NormalizeURL]
|
||||
['Captcha Replacement', Captcha.replace]
|
||||
['Redirect', Redirect]
|
||||
['Header', Header]
|
||||
|
||||
14
src/Miscellaneous/NormalizeURL.coffee
Normal file
14
src/Miscellaneous/NormalizeURL.coffee
Normal file
@ -0,0 +1,14 @@
|
||||
NormalizeURL =
|
||||
init: ->
|
||||
return unless Conf['Normalize URL']
|
||||
|
||||
pathname = location.pathname.split /\/+/
|
||||
switch g.VIEW
|
||||
when 'thread'
|
||||
pathname[2] = 'thread'
|
||||
pathname = pathname[0...4]
|
||||
when 'index'
|
||||
pathname = pathname[0...3]
|
||||
pathname = pathname.join '/'
|
||||
if location.pathname isnt pathname
|
||||
history.replaceState history.state, '', "#{location.protocol}//#{location.host}#{pathname}#{location.hash}"
|
||||
Loading…
x
Reference in New Issue
Block a user