mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
regex rewrite: fix js regex (dashes), add additional test case
This commit is contained in:
parent
841fd3f7b4
commit
a3b931b45e
@ -111,7 +111,8 @@ class JSLinkOnlyRewriter(RegexRewriter):
|
|||||||
JS Rewriter which rewrites absolute http://, https:// and // urls
|
JS Rewriter which rewrites absolute http://, https:// and // urls
|
||||||
at the beginning of a string
|
at the beginning of a string
|
||||||
"""
|
"""
|
||||||
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\';&\\])'
|
||||||
|
JS_HTTPX = r'(?<=["\';])(?:https?:)?\\{0,4}/\\{0,4}/[A-Za-z0-9:_@.\-/\\?&#]+(?=["\';&\\])'
|
||||||
|
|
||||||
def __init__(self, rewriter, rules=[]):
|
def __init__(self, rewriter, rules=[]):
|
||||||
rules = rules + [
|
rules = rules + [
|
||||||
|
@ -61,6 +61,9 @@ r"""
|
|||||||
>>> _test_js('"http:\\/\\/www.example.com\\/some\\/path\\/?query=1"')
|
>>> _test_js('"http:\\/\\/www.example.com\\/some\\/path\\/?query=1"')
|
||||||
'"/web/20131010/http:\\/\\/www.example.com\\/some\\/path\\/?query=1"'
|
'"/web/20131010/http:\\/\\/www.example.com\\/some\\/path\\/?query=1"'
|
||||||
|
|
||||||
|
>>> _test_js('"http:\/\/sub-site.example.com\/path-dashes\/path_other\/foo_bar.txt"')
|
||||||
|
'"/web/20131010/http:\\/\\/sub-site.example.com\\/path-dashes\\/path_other\\/foo_bar.txt"'
|
||||||
|
|
||||||
|
|
||||||
#=================================================================
|
#=================================================================
|
||||||
# XML Rewriting
|
# XML Rewriting
|
||||||
|
Loading…
x
Reference in New Issue
Block a user