File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -220,12 +220,15 @@ def map_token(original: str, replacement: str) -> str:
220220 # To ensure the same url matching behavior, do the same.
221221 split = resolved_url .split ("://" , maxsplit = 1 )
222222 if len (split ) == 2 :
223- core_url = "http://" + split [1 ]
223+ # URL parser doesn't like strange/unknown schemes, so we replace it for parsing, then put it back
224+ parsable_url = "http://" + split [1 ]
224225 else :
225- core_url = match
226- parsed = urlparse (core_url , allow_fragments = True )
226+ # Given current rules, this should never happen _and_ still be a valid matcher. We require the protocol to be part of the match,
227+ # so either the user is using a glob that starts with "*" (and none of this code is running), or the user actually has `something://` in `match`
228+ parsable_url = resolved_url
229+ parsed = urlparse (parsable_url , allow_fragments = True )
227230 if len (split ) == 2 :
228- # urlparse doesn't like stars in the scheme
231+ # Replace the scheme that we removed earlier
229232 parsed = parsed ._replace (scheme = split [0 ])
230233 if parsed .path == "" :
231234 parsed = parsed ._replace (path = "/" )
Original file line number Diff line number Diff line change @@ -1102,7 +1102,6 @@ def glob_to_regex(pattern: str) -> re.Pattern:
11021102 "http://mydomain:8080/blah/blah/three-columns/settings.html?id=settings-e3c58efe-02e9-44b0-97ac-dd138100cf7c&blah"
11031103 )
11041104
1105- print (glob_to_regex ("\\ ?" ).pattern )
11061105 assert glob_to_regex ("\\ ?" ).pattern == r"^\?$"
11071106 assert glob_to_regex ("\\ " ).pattern == r"^\\$"
11081107 assert glob_to_regex ("\\ \\ " ).pattern == r"^\\$"
@@ -1156,6 +1155,16 @@ def glob_to_regex(pattern: str) -> re.Pattern:
11561155 assert url_matches ("http://first.host/" , "http://second.host/foo" , "**/foo" )
11571156 assert url_matches ("http://playwright.dev/" , "http://localhost/" , "*//localhost/" )
11581157
1158+ # Added for Python implementation
1159+ assert url_matches (
1160+ None ,
1161+ "custom://example.com/foo/bar?id=123" ,
1162+ "{custom,another}://example.com/foo/bar?id=123" ,
1163+ )
1164+ assert not url_matches (
1165+ None , "custom://example.com/foo/bar?id=123" , "**example.com/foo/bar?id=123"
1166+ )
1167+
11591168
11601169async def test_should_not_support_question_in_glob_pattern (
11611170 page : Page , playwright : Playwright , server : Server
You can’t perform that action at this time.
0 commit comments