-
Notifications
You must be signed in to change notification settings - Fork 322
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
Relative URLs with unknown base #487
Comments
I think I would call this outside of the scope of this crate. The What transformation do you need to do on those URL strings? |
The main operation I need right now is to resolve a url from a base. e.g. if we encountered the url Correctly handling absolute URLs, absolute paths, query params and hashes, not to mention encoding makes for a decent amount of code and a lot of overlap with other url handling. |
In terms of implementation I expect that dealing with In terms of public API, I expect this new feature would be entirely separate from what’s already in the For these reasons I think this would be better in a separate crate. Feel free to copy some of the code according to the license, though. |
To me, this issue sounds like a confusion between URLs and URIs. My understanding is that the use case that @rictic described pertains to URIs, because they are relative paths without a base at compile-time. IIRC, URLs are explicitly required to have absolute paths. Given the above, I'd suggest the author to look into using the http crate for URI parsing. See hyperium/http#73 for more information about the history behind http not including the url crate as one of its components, in particular this comment from @SimonSapin |
I don’t believe that’s what the difference between URL and URI is. But I also don’t believe that distinction is useful at all, or relevant here. |
Seems reasonable, thanks! |
I'm writing some code that transforms source code, specifically URL strings in HTML, CSS, and JS. These URLs may be relative (e.g.
./foo.js
,/bar.css
,../search?query=cats
) and my code won't have the context of the base URL that these URLs would be interpreted relative to at runtime.I didn't see any public API that supports parsing or providing structured handling of this sort of URL. Is it a use case you'd be interested in supporting?
The text was updated successfully, but these errors were encountered: