Skip to content
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

fix(js-runtime): bring URL closer to the standard #253

Merged
merged 1 commit into from Dec 17, 2022

Conversation

cyco130
Copy link
Contributor

@cyco130 cyco130 commented Nov 13, 2022

This PR brings the URL class closer to the standard. In particular it adds the ability to reflect the changes to the href property when a part is updated: e.g. when searchParams.set is called.

Copy link
Member

@QuiiBz QuiiBz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Have a few suggestions, let me know if you want to/can implement username/password for href in this PR or not.

@@ -80,6 +81,48 @@
throw new Error('Not implemented');
}

get href(): string {
// TODO: username and password
let href = this.protocol + '//' + this.host + this.pathname + this.search + this.hash;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also implement username/password in this PR? We should only add the username -> password separator : if both of them are non-empty strings. If at least the username is set, we can add a @ separator before the host.


set search(search: string) {
// TODO: Probably not spec compliant, all tested engines keep the same searchParams object
this.searchParams = new URLSearchParams(search);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating a new object, we can get and delete all entries and append() the new ones by applying the same logic as in URLSearchParams's constructor. Some libs might expect the reference to be the same, which will fail in this case.

@QuiiBz
Copy link
Member

QuiiBz commented Nov 25, 2022

Hi @cyco130, do you have the time to fix the above comments? If not, do not hesitate to tell me and I'll fix it :)

I'm also curious to see the before/after within the web-platform-tests runner that was added a few days ago (#270)

@cyco130
Copy link
Contributor Author

cyco130 commented Nov 25, 2022

Hi @QuiiBz,

Sorry for the radio silence :) I'll have some time this weekend and this PR is definitely on my todo.

Ooh, great web-platform-tests integration is a great idea!

@cyco130
Copy link
Contributor Author

cyco130 commented Dec 17, 2022

Hi,

I'm trying to come back to this but I get the following error when I try to run the unit tests:

ReferenceError: document is not defined
 ❯ fixFileAndXHR ../../node_modules/.pnpm/blob-polyfill@7.0.20220408/node_modules/blob-polyfill/Blob.js:530:27
 ❯ ../../node_modules/.pnpm/blob-polyfill@7.0.20220408/node_modules/blob-polyfill/Blob.js:588:4
 ❯ ../../node_modules/.pnpm/blob-polyfill@7.0.20220408/node_modules/blob-polyfill/Blob.js:18:4
 ❯ ../../node_modules/.pnpm/blob-polyfill@7.0.20220408/node_modules/blob-polyfill/Blob.js:23:4
 ❯ Object.<anonymous> ../../node_modules/.pnpm/blob-polyfill@7.0.20220408/node_modules/blob-polyfill/Blob.js:701:3

Any idea how to proceed?

@QuiiBz
Copy link
Member

QuiiBz commented Dec 17, 2022

Hi! Strange issue, I'm not able to reproduce it. Make sure to rebase + pnpm install, I've made many changes inside the js-runtime package.

@vercel
Copy link

vercel bot commented Dec 17, 2022

@cyco130 is attempting to deploy a commit to the Lagon Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Dec 17, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
docs ✅ Ready (Inspect) Visit Preview Dec 17, 2022 at 7:30PM (UTC)
storybook ✅ Ready (Inspect) Visit Preview Dec 17, 2022 at 7:30PM (UTC)

@cyco130
Copy link
Contributor Author

cyco130 commented Dec 17, 2022

I think my Rust setup is screwed up, that's why I keep getting weird issues :)

Anyway, I tried to address the issues in your review and included tests for those cases.

Copy link
Member

@QuiiBz QuiiBz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks again!

@QuiiBz QuiiBz merged commit 683e635 into lagonapp:main Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants