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
URL constructor is missing 'base' option #569
Comments
BTW I think the |
Hi! @silverwind😊. Thank you for your feedback. |
Oh, any you shouldn't forget |
No, I don't approve. my test unit. const wg = require("whatwg-url");
console.time("whatwg-url");
for (let i = 0; i < 1000000; i++) {
new wg.URL('', 'https://example.com');
}
console.timeEnd("whatwg-url");
console.time("node:url");
for (let i = 0; i < 1000000; i++) {
new URL('', 'https://example.com');
}
console.timeEnd("node:url"); test parse 1 million times, |
Interesting, they must've done some additional optimizations not present in |
Maybe. I don't look closely, you can see the implementation of |
It's in https://github.com/nodejs/node/blob/v18.7.0/lib/internal/url.js. Definitely contains various low-level optimizations. Maybe as a solution, you could check if running on node, use |
After a lot of debugging, I stumbled upon the same issue. In my case I was trying to replace jsdom by happydom for our tests but this is not possible because of this issue. MSW is relying on this constructor (and I'm sure many other libraries do): https://github.com/mswjs/interceptors/blob/main/src/utils/getUrlByRequestOptions.ts#L91 It would be awesome if happy-dom could add this. :) |
Found my way here via the vitest |
Hi @shayneo! 🙂 Great that you want to contribute. However, I believe that me and @Mas0nShi are already working on a PR related to this, which should solve it. We will remove the custom URL implementation and replace it with Nodes. You can see the change here: |
Thanks for the quick reply @capricorn86! Looks like this is well underway. |
We have now fixed this by using the native You can read more about the release here: |
The URL constructor at
happy-dom/packages/happy-dom/src/location/URL.ts
Line 23 in 57a8d33
base
url:Quick test:
The text was updated successfully, but these errors were encountered: