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

Implement Missing Methods in URL Class to Handle Base URL and Relative Path Combinations #45055

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

sossost
Copy link

@sossost sossost commented Jun 19, 2024

Summary:

close #45030

The window.URL object is available in Hermes but was previously unimplemented, with all accessors throwing TODO Errors. This pull request implements the missing methods to ensure correct handling of base URLs and relative paths.

Changelog:

[ANDROID] [FIXED] - Implemented missing methods in the URL class to handle base URL and relative path combinations.

Test Plan:

@facebook-github-bot
Copy link
Contributor

Hi @sossost!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 19, 2024
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jun 19, 2024
@sossost sossost changed the title Feat : Implement Missing Methods in URL Class to Handle Base URL and Relative Path Combinations Implement Missing Methods in URL Class to Handle Base URL and Relative Path Combinations Jun 19, 2024
@cortinico
Copy link
Contributor

Thanks for sneding this over @sossost
Can we make the CI green before we can review/import this?

@sossost
Copy link
Author

sossost commented Jun 19, 2024

@cortinico oh! sorry I've updated the CI to green.

@facebook-github-bot
Copy link
Contributor

@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@NickGerleman
Copy link
Contributor

The parsing behavior of URL global is pretty decently specced out: E.g. https://url.spec.whatwg.org/#concept-basic-url-parser

The reference implementation is pretty different from how functions are implemented in this PR. At a glance, I can see we're doing a lot of splitting, and regexing against specific patterns. Spec seems to rely on a lot more context.

One of the core differences, is that, we parse during construction (I see we already have a validation step), and the parsing steps themselves will determine the value for different URL fields. So, we don't do separate string manipulation when trying to access a URL field. We have already set these during parsing.

@sossost would it be possible to base the implementation of these new fields, derived from behavior prescribed in parsing spec?

@sossost
Copy link
Author

sossost commented Jun 25, 2024

@NickGerleman I'll take a look at that and fix it, thanks for the nice feedback.

hash: string,
origin: string,
} {
const urlPattern =
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does this regex come from?

At a quick glance, I know we should be more permissive in allowing schemes that are not just http.

Copy link
Author

Choose a reason for hiding this comment

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

@NickGerleman Oh I almost missed that, I'm not good enough to see that, thanks for the advice.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we getting this regex from a source, or trying to derive it?

Copy link
Author

Choose a reason for hiding this comment

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

@NickGerleman No, I didn't get this regex from a source. I derived it myself.

@cortinico
Copy link
Contributor

@sossost can you make the CI green before we can import/merge this one?

@sossost
Copy link
Author

sossost commented Jul 4, 2024

I apologize. I have some additional fixes to make, but I've been so busy I haven't had time to work on them. I'll update them soon, thank you.

@cortinico
Copy link
Contributor

I apologize. I have some additional fixes to make, but I've been so busy I haven't had time to work on them. I'll update them soon, thank you.

Great 👍 Please ping me when you're ready

@migueldaipre
Copy link
Collaborator

@sossost Friendly ping.

Any progress? Anything I can help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Finish implementing URL accessors like host, hostname, username, password
5 participants