Comments (10)
More eager than that: any attempt to construct a file:
URI without a rooted path will emit a warning at instantiation time unless that warning is explicitly silenced. I like to notify people of incoming foot-shots before they pull the trigger. ;)
from uri.
This may very well partially be a duplicate of #9. Please reference this comment, specifically. I also note that your MCVE (test case) does not ever actually define the variable u2
, making it incomplete.
Edited to add relevant ABNF:
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
hier-part = "//" authority path-abempty
/ path-absolute
/ path-rootless
/ path-empty
URI-reference = URI / relative-ref
absolute-URI = scheme ":" hier-part [ "?" query ]
relative-ref = relative-part [ "?" query ] [ "#" fragment ]
relative-part = "//" authority path-abempty
/ path-absolute
/ path-noscheme
/ path-empty
from uri.
Sorry about the lack of u2
-- I've fixed the original message (copy and paste error).
from uri.
Reading the comment referenced above in #9, I agree with the last line of the first paragraph (it doesn't round trip properly). The final comment on #9 seems to be that file:relative/path.ext
is forbidden by the RFC and is not in fact described by the path-rootless
section of the documentation. The odd thing is that this package is parsing them correctly, but not putting them back together consistently.
from uri.
Thank you for the updated test case; I'll get this integrated into the test suite proper and make sure roundtrips behave sanely. Specifically, examining the BNC closely, it appears that without the //
marker, there is no authority part, vs. URI's current behaviour of treating everything up to the first /
(after the first :
, ignoring //
) as authority.
from uri.
As per the notes (and "final weigh-in") from this comment on #9, and the RFC specification for the file:
URI scheme (BNF copied below), "relative" paths are not permitted.
file-URI = file-scheme ":" file-hier-part
file-scheme = "file"
file-hier-part = ( "//" auth-path )
/ local-path
auth-path = [ file-auth ] path-absolute
local-path = path-absolute
file-auth = "localhost"
/ host
Identity transform round-trips for structurally invalid values can not be assured; I will be adding the capability for Scheme implementations to perform validation such that a warning can be issued if an attempt is made to utilize a path-relative
component. (On a custom FileScheme, not the base URLScheme, given it's scheme-specific behaviour.)
from uri.
Thank you for pointing me at RFC8089. I agree that that says that relative paths are not supported in file scheme. RFC3986 doesn't care but RFC8089 overrides that.
from uri.
Would it be possible to issue a warning if a URI string is being created from a file relative path so that the round trip failure is more obvious?
from uri.
Would it be possible to issue a warning if a URI string is being created from a file relative path so that the round trip failure is more obvious?
Absolutely; that is what my last comment was trying to state is my plan. It shouldn't outright fail (since there does seem to be a general sense that //
-omitting file:
is "acceptable" to humans, but it certainly should issue a warnings.warn
.
from uri.
Great. Just to confirm what I think you are saying, file:relative/path.ext
should be accepted as now (as also happens with furl
and urllib
) but if someone asks for the URI string to be reconstructed a warning should be issued because now it has taken a relative path
and converted it to an absolute path.
from uri.
Related Issues (20)
- Use slice notation on URI's for authentication creds HOT 3
- Add method to reconstruct the request URI from a WSGI environment. HOT 2
- Missing scheme HOT 3
- Utilize "services" index for default port identification.
- Implement "URL fopen"-like behavior.
- Support and utilise native IP address representations. HOT 3
- Automatically handle punycode encoding and decoding. HOT 2
- Deprecation Warning for import of namedtuple from collections instead of collections.abc HOT 7
- disappearing "//" HOT 10
- Implement Python __hash__ method to permit use as dictionary keys and set members. HOT 7
- URI with empty path HOT 9
- URI variant that pulls in page titles during HTML expansion.
- ImportError: cannot import name 'ItemsView' from 'collections' HOT 1
- Correct Pretty-RFC links. HOT 1
- Add "yarl" to the "Migrating"-section in the README
- Please release 3.0.0 HOT 3
- Make "empty path element" handling more explicit.
- Host/host:port and path aren't definitively separated by a slash HOT 7
- For some schemes, URLs with no authority are rendered incorrectly HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uri.