Skip to content

Commit

Permalink
Merge pull request #289 from adrienthiery/fix/hashtag-url
Browse files Browse the repository at this point in the history
fix: url validator considers urls with /#/ as valid
  • Loading branch information
yozachar committed Aug 18, 2023
2 parents ee088fa + 4015e8e commit 9e94fee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/validators/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def _validate_optionals(path: str, query: str, fragment: str):
if query:
optional_segments &= bool(_query_regex().match(query))
if fragment:
fragment = fragment.lstrip("/") if fragment.startswith("/") else fragment
optional_segments &= all(char_to_avoid not in fragment for char_to_avoid in ("/", "?"))
return optional_segments

Expand Down
1 change: 1 addition & 0 deletions tests/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"https://travel-usa.com/wisconsin/旅行/",
"http://:::::::::::::@exmp.com",
"http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
"https://exchange.jetswap.finance/#/swap",
# when simple_host=True
# "http://localhost",
# "http://localhost:8000",
Expand Down

0 comments on commit 9e94fee

Please sign in to comment.