Skip to content

Commit 9e94fee

Browse files
authored
Merge pull request #289 from adrienthiery/fix/hashtag-url
fix: url validator considers urls with /#/ as valid
2 parents ee088fa + 4015e8e commit 9e94fee

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/validators/url.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def _validate_optionals(path: str, query: str, fragment: str):
116116
if query:
117117
optional_segments &= bool(_query_regex().match(query))
118118
if fragment:
119+
fragment = fragment.lstrip("/") if fragment.startswith("/") else fragment
119120
optional_segments &= all(char_to_avoid not in fragment for char_to_avoid in ("/", "?"))
120121
return optional_segments
121122

tests/test_url.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
"https://travel-usa.com/wisconsin/旅行/",
8585
"http://:::::::::::::@exmp.com",
8686
"http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
87+
"https://exchange.jetswap.finance/#/swap",
8788
# when simple_host=True
8889
# "http://localhost",
8990
# "http://localhost:8000",

0 commit comments

Comments
 (0)