mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
rewrite: fix js rewrite again to ensure '// comments' are not rewritten as scheme-rel urls
add tests
This commit is contained in:
parent
bf0996c27a
commit
6acac67d3c
@ -113,7 +113,7 @@ class JSLinkRewriterMixin(object):
|
||||
"""
|
||||
#JS_HTTPX = r'(?:(?:(?<=["\';])https?:)|(?<=["\']))\\{0,4}/\\{0,4}/[A-Za-z0-9:_@.-]+.*(?=["\s\';&\\])'
|
||||
#JS_HTTPX = r'(?<=["\';])(?:https?:)?\\{0,4}/\\{0,4}/[A-Za-z0-9:_@.\-/\\?&#]+(?=["\';&\\])'
|
||||
JS_HTTPX = r'(?<=["\';])(?:https?:)?\\{0,4}/\\{0,4}/[A-Za-z0-9:_@.-]'
|
||||
JS_HTTPX = r'(?<=["\';])(?:https?:)?\\{0,4}/\\{0,4}/[A-Za-z0-9:_@.-][^"\s\';&\\]*(?=["\';&\\])'
|
||||
|
||||
def __init__(self, rewriter, rules=[]):
|
||||
rules = rules + [
|
||||
|
@ -32,6 +32,13 @@ r"""
|
||||
>>> _test_js(r'location = "http://example.com/abc.html?^foo=http://abc.example.com"')
|
||||
'WB_wombat_location = "/web/20131010/http://example.com/abc.html?^foo=http://abc.example.com"'
|
||||
|
||||
# don't rewrite comments, only scheme rel urls
|
||||
>>> _test_js(r'location = "http://example.com/abc.html?^foo=http://abc.example.com";//some comments')
|
||||
'WB_wombat_location = "/web/20131010/http://example.com/abc.html?^foo=http://abc.example.com";//some comments'
|
||||
|
||||
>>> _test_js(r'location = "//example.com/abc.html?^foo=http://abc.example.com"//some comments')
|
||||
'WB_wombat_location = "/web/20131010/http://example.com/abc.html?^foo=http://abc.example.com"//some comments'
|
||||
|
||||
# not rewritten -- to be handled on client side
|
||||
>>> _test_js(r'location = "/abc.html"')
|
||||
'WB_wombat_location = "/abc.html"'
|
||||
|
Loading…
x
Reference in New Issue
Block a user