make URL normalization optional

This commit is contained in:
ccd0 2014-06-29 16:01:21 -07:00
parent 78e87d232a
commit eaa7e87d00
3 changed files with 11 additions and 4 deletions

View File

@ -97,6 +97,10 @@ Config =
true
'Warn if your browser or configuration is unsupported and may cause 4chan X to not operate correctly.'
]
'Normalize URL': [
true
'Rewrite the URL of the current page, removing stubs and changing /res/ to /thread/.'
]
'Linkification':
'Linkify': [

View File

@ -16,9 +16,6 @@ Main =
'index'
if g.VIEW is 'thread'
g.THREADID = +pathname[3]
if pathname[2] isnt 'thread' or pathname.length > 4
pathname[2] = 'thread'
history.replaceState null, '', pathname.slice(0,4).join('/') + location.hash
# flatten Config into Conf
# and get saved or default values
@ -65,6 +62,12 @@ Main =
if video.paused then video.play() else video.pause()
return
if Conf['Normalize URL'] and g.VIEW is 'thread'
pathname = location.pathname.split '/'
if pathname[2] isnt 'thread' or pathname.length > 4
pathname[2] = 'thread'
history.replaceState null, '', pathname.slice(0,4).join('/') + location.hash
# c.time 'All initializations'
for [name, feature] in Main.features
# c.time "#{name} initialization"

View File

@ -119,7 +119,7 @@ class Post
return unless match = quotelink.href.match ///
boards\.4chan\.org/
([^/]+) # boardID
/(?:res|thread)/\d+#p
/(?:res|thread)/\d+(?:\/[^#]*)?#p
(\d+) # postID
$
///