-
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
username/password/port should be removed when "file" is added as scheme #259
Comments
We should probably not allow setting to file under those conditions. That's what we do for similar situations elsewhere (e.g., setting host to the empty string when port is non-empty). |
The basis why this behavior should avoid is that it allows having an invalid URL in the var url = new URL('http://user:[email protected]:21/aaa/zzz?l=24#test');
url.protocol = 'file:';
var url2 = new URL(url.href);
// => Uncaught TypeError: Failed to construct 'URL': Invalid URL
// at <anonymous>:1:1
// (anonymous) @ VM326:1 As another workaround, it can escape the invalid character strings, but it's more predictable and natural to delete automatically imho because the properties such as |
I still think making the setter fail (return early) is the most consistent. |
I just noticed that var url = new URL('http://example.com');
url.href = 'file://user:pass%40foo.bar.com:21/aaa/zzz?l=24#test'; Then this issue is not an exception anymore. Fair enough :) Thanks, I'm going to close this as resolved. |
I don't think that's true per the URL Standard? |
In particular, |
The essential point of this issue report is that whether the latter part of the below is correct or not: Errors should be thrown when an invalid URL string is passed to the constructor, and also errors should be thrown too when an invalid property is set to the instance of the URL. If |
I'm not sure I follow what you're saying. Setting |
As file URLs cannot have username/password/port we don’t want to allow changing the scheme of a URL that contains one or more of those components. Fixes #259.
I posted a PR, would appreciate a review @watilde. I'll also write some tests. |
Wow that's great. I will check it now 😃 |
As file URLs cannot have username/password/port we don’t want to allow changing the scheme of a URL that contains one or more of those components. Similarly a file URL can have an empty/null host, changing the scheme to another special URL that cannot have such a host would be bad. Fixes #259 and fixes #270.
As file URLs cannot have username/password/port, we should not keep them when scheme is changed to file. Refs: whatwg/url#259
According to this section in the spec, the file scheme can't have
username/password/port
. I think they also should be removed automatically whenfile:
is added as the scheme. Currently, they are left in thehref
even they cannot be overwritten.e.g.
The text was updated successfully, but these errors were encountered: