You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there,
following #285 's report, we also saw a regression on testing validity or a URL, namely https://exchange.jetswap.finance/#/swap ( ValidationError(func=url, args={'value': 'https://exchange.jetswap.finance/#/swap'})
The /#/ in there is probably the thing making it match as invalid, sadly it is a common side-effect of some JS UI libraries.
As the last comments mention, it would indeed be super nice to follow the common semver practice in bumping a major version in case of breaking change, and at least mention in the releases description when a breaking change is included. 🙏
The /#/ in there is probably the thing making it match as invalid, sadly it is a common side-effect of some JS UI libraries.
Hi @adrienthiery, indeed, /#/ was causing trouble, but this was not an intentional breaking change, unlike the case in #285 (comment). It is an edge case which was neither present in the tests before nor afterv0.20.0. But since the validation algorithm changed, the edge case popped up.
When the URL https://exchange.jetswap.finance/#/swap is passed, fragment = /swap, which makes optional_segments = false since / is present in the fragment, which is (an) unusual (side-effect) as you suggest.
Here's the patch.
if fragment:
+ fragment = fragment.lstrip("/") if fragment.startswith("/") else fragment
optional_segments &= all(char_to_avoid not in fragment for char_to_avoid in ("/", "?")
This will handle all the URLs with /#/some-value fragment in them, but I think there will be more edge cases, only time will tell. PRs are welcome!
changed the title [-]Breaking change between 0.20 and latest version (URLs including `/#/`)[/-][+]bug: `/#/` in URLs is failing validation[/+]on Aug 17, 2023
Activity
nandgator commentedon Aug 17, 2023
Hi @adrienthiery, indeed,
/#/was causing trouble, but this was not an intentional breaking change, unlike the case in #285 (comment). It is an edge case which was neither present in the tests before nor afterv0.20.0. But since the validation algorithm changed, the edge case popped up.Currently
src/validators/url.pyhas:validators/src/validators/url.py
Lines 118 to 119 in ee088fa
When the URL
https://exchange.jetswap.finance/#/swapis passed,fragment = /swap, which makesoptional_segments = falsesince/is present in the fragment, which is (an) unusual (side-effect) as you suggest.Here's the patch.
if fragment: + fragment = fragment.lstrip("/") if fragment.startswith("/") else fragment optional_segments &= all(char_to_avoid not in fragment for char_to_avoid in ("/", "?")This will handle all the URLs with
/#/some-valuefragment in them, but I think there will be more edge cases, only time will tell. PRs are welcome![-]Breaking change between 0.20 and latest version (URLs including `/#/`)[/-][+]bug: `/#/` in URLs is failing validation[/+]cfi-gb commentedon Sep 6, 2023
It seems a few additional ones have been found so far and #296 has been raised as a follow-up with additional different examples.