diff --git a/src/General/Main.coffee b/src/General/Main.coffee index add8ed36d..6faa43d3f 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -130,17 +130,6 @@ Main = # set up CSS when 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] diff --git a/src/Miscellaneous/NormalizeURL.coffee b/src/Miscellaneous/NormalizeURL.coffee new file mode 100644 index 000000000..f059ef72a --- /dev/null +++ b/src/Miscellaneous/NormalizeURL.coffee @@ -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}"