Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent handling of special characters in DecodedURL #164

Open
deains opened this issue May 4, 2021 · 0 comments
Open

Inconsistent handling of special characters in DecodedURL #164

deains opened this issue May 4, 2021 · 0 comments

Comments

@deains
Copy link

deains commented May 4, 2021

Working with DecodedURL objects is problematic if the URL contains special characters. Because attributes like url.path do not return the raw value, you get some weird behaviour using replace:

>>> from hyperlink import parse
>>> url = parse('https://www.example.com/game/Saints-Row:-The-Third')
>>> url == url.replace()
True
>>> url == url.replace(host=url.host)
True
>>> url == url.replace(path=url.path)
False
>>> url.path == url.replace(path=url.path).path
True

In the docs there's this line about encoding:

DecodedURL automatically handles encoding and decoding all its components, such that all inputs and outputs are in a maximally-decoded state.

This does not seem to be the case as if DecodedURL was doing this, these equalities would always be True, unless I'm misunderstanding something (entirely possible 🙃).

Working with parse('…', decoded=False) instead seems to solve this problem, although I'm not sure if that's the "right" solution to this.

This situation was very confusing to me, especially since normalize() didn't seem to have any effect at all (although reading the docs for it, I'm not actually sure if it should or not).

I'm unsure if this behaviour is a bug, or it's just me not using the library the right way. Either way, I'd appreciate your input!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant