-
Notifications
You must be signed in to change notification settings - Fork 7
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
URI with empty path #22
Comments
Indeed, Looking at practical implications, the encoding (REPR, in this case) containing the slash appears to be a result of the attempt to form the >>> URI('http://example.com')
<<< URI('http://example.com/')
>>> URI('http://example.com').path
<<< PurePosixPath('.') Resolution of Conversely, the paths you have given as examples are the same URI after absolutizing. The first bullet point case below this section covers this situation, I believe. |
Yes after absolutizing it might be the same. |
Additional note: the relative reference resolution examples appear to strongly prefer that if a path has ever existed, that a root must be preserved:
|
I would not draw conclusions about preferences from examples. Better stick with the specification |
Examining the code, you can "hotfix" patch this behavior yourself if required: from uri.part.path import PathPart
PathPart.empty = "" That will swap out the default representation for an "empty" path globally: >>> URI('http://example.com')
<<< URI('http://example.com')
>>> URI('http://example.com/foo')
<<< URI('http://example.com/foo') I may have already thought about this, then forgotten. 😜 Edit to note: my desire has been to follow the specification as closely as is reasonable, while making sensible accomodations for user-expected behavior, i.e. as experienced in a browser user agent. In a majority of the browsers I utilize, if you omit the trailing
Double check where these examples are literally coming from. |
Am I correct that with your hotfix, the issue would reappear the other way round? so that
These are examples from the spec. So ? |
Nope, but that's a trivial one to try out: >>> URI('http://example.com/')
<<< URI('http://example.com/') The adaption is explicit, as mentioned, targeting the |
Ok good! Sounds like the way to go. |
This will require discussion/debate; changing default behaviours is not often an easy decision. Which to target: pure specification, or practical application? The Zen of Python does have something to say about this, and alteration of behavior to match specific desires is demonstrably quite simple. Explicitly why I structured the representation into "parts" the way I have. Consider it less of a "hotfix" than configuration, if you need to. This configuration also only alters behavior for your own application process; it merely isn't passed in as part of the constructor itself, it's process-global. (It's not like monkeypatching code paths—this is just the alteration of a global constant dedicated for this explicit purpose!) |
From the wiki https://en.wikipedia.org/wiki/Uniform_Resource_Identifier
So this should be correct uri
https://localhost
(notice no slash at the end)
However
The text was updated successfully, but these errors were encountered: