-
Notifications
You must be signed in to change notification settings - Fork 139
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
Allow //
when base exists
#553
Comments
I suspect this doesn't work because (new URL('//foo', 'http://localhost:3000')).href
// => "http://foo/" |
Right, that's the current spec's behavior. What the original test case tried to handling new (URL('/.//', 'http://localhost:3000).href
// => "http://localhost:3000//" I'm wondering if it's worth letting |
Wouldn't it be extremely confusing that Looking at nodejs/node#35458 I think what you want is something like this let finalURL = null;
try {
finalURL = new URL(req.url);
} catch (e) {
if (req.url.startsWith("/") {
finalURL = new URL(`http://${req.headers.host}${req.url}`); // can you trust .host though?
}
} but it's worth clarifying with the HTTP specification what the exact behavior should be there (e.g., this does not account for |
This is a good point and I realized that we might not know if users want to handle the input as host or path in this case since
* |
I forgot above that setting https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-semantics-19#section-4.1 is pretty clear that this is a special production that is different from the one that does not allow Closing this therefore, but feel free to leave comments in case I missed something. |
As
new URL('http://localhost:3000//')
is allowed,new URL('//', 'http://localhost:3000')
should work to have the same beheivour.Steps to reproduce with
whatwg-url
The text was updated successfully, but these errors were encountered: