-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Wrong formatting of url in urlunsplit() function when used with _replace function to change scheme #99901
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
Comments
urlparse("8.8.8.8:1337", scheme='http').geturl() will also produce |
I think that the issue is not in
'8.8.8.8:1337' is expected to be a netlock, not path. Or maybe it is incorrectly used. |
Actually, it is explicitly mentioned in the docs.
And indeed it works if you prepend
So the question is if we want to handle cases when netloc is empty when |
The question is how to handle URLs with empty netloc and relative path.
Option 1 is used for schemes that do not use netloc, option 2 is currently used for schemes that use netloc (e.g. So I think that this issue should be closed as "not a bug". The question about empty netloc and relative path is discussed in #85110. |
When is this going to get fixed? |
See #85110. |
Bug report
This prints ''http:///8.8.8.8:1337", but should have printed "http://8.8.8.8:1337".
Note the three slashes.
The reason is that the urlunsplit function in Lib/urllib/parse.py checks whether the original url contains a slash, which is not the case, adds a slash and then adds two more slashes.
Your environment
Linked PRs
The text was updated successfully, but these errors were encountered: