-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Use the same parse processing at contractor of URL with setters #1549
Conversation
query: urlParts.query || baseParts.query, | ||
hash: urlParts.hash | ||
}; | ||
this._parts = initializedURLParts; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary? How is this related to the issue mentioned in the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this means every instance of URL
that does not have protocol, but has baseParts
would share the same instance of this._parts
which sounds very bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the beginning, I thought the same but turned out setter will refuse provided value if there is no initialized Object in _parts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test in js/url_test.ts
const url = new URL('http:https://example.com/パス');
console.log(url.pathname);
// => /%E3%83%91%E3%82%B9
url.pathname = 'パス';
console.log(url.pathname);
// => /%E3%83%91%E3%82%B9 |
@kitsonk That's right. The punycode support is what I'd love to have eventually, but I'd prefer to take a small step to reach out to there. I'm wondering if it's ok to just wrap the official |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks
@ry, @watilde this still has a problem... This comment was not addressed:
I don't think this should have been merged. I am still missing the purpose of it, because in the constructor, the Right now every instance of const a = new URL("/bar", "https://example.com/");
const b = new URL("/baz", "https://example.com/");
console.log(a.pathname); // "/baz"
console.log(b.pathname): // "/baz"
a.pathname = "/bar";
console.log(a.pathname); // "/bar"
console.log(b.pathname): // "/bar" Can we please revert and fix the issue properly? |
…rs (denoland#1549)" Right now every instance of URL which has a basePath passed will share the same instance of parts, so a change to one of them will change them all. denoland#1549 (comment) This reverts commit 9e1f5cc.
…rs (#1549)" Right now every instance of URL which has a basePath passed will share the same instance of parts, so a change to one of them will change them all. #1549 (comment) This reverts commit 9e1f5cc.
…rs (#1549)" Right now every instance of URL which has a basePath passed will share the same instance of parts, so a change to one of them will change them all. denoland/deno#1549 (comment) This reverts commit 9e1f5cc.
Problem this patch fixes
Currently, contractor of URL does not use the same parse processing with the setters in the Class and it makes inconsistent behaviour. See the code below and this patch is to fix the issue.
There is more missing implementation around ASCII encoding at URL and I'm working on it based on this patch. Let me know if you have any question.
Code to reproduce