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

init url module #304

Merged
merged 1 commit into from
Mar 26, 2024
Merged

Conversation

imaitland
Copy link
Contributor

@imaitland imaitland commented Mar 25, 2024

Issue # (if available)

#214

Description of changes

Adopt WHATWG URL Spec for ESM import syntax: https://nodejs.org/api/url.html#new-urlinput-base

The URL constructor is accessible as a property on the global object. It can also be imported from the built-in url module

import { URL, URLSearchParams } from "url";

Also noticed there was a bug in URL.canParse() and fixed it.

Caveats

Original ticket: #195 requested URL.parse however this has been deprecated, https://nodejs.org/api/url.html#urlparseurlstring-parsequerystring-slashesdenotehost,

url.parse() uses a lenient, non-standard algorithm for parsing URL strings. It is prone to security issues such as host name spoofing and incorrect handling of usernames and passwords. Do not use with untrusted input. CVEs are not issued for url.parse() vulnerabilities. Use the WHATWG URL API instead.

though it does seem to be used fairly widely, a succinct description of the situation is here: nodejs/node#12682 (comment)

along with discussion within WHATWG here: whatwg/url#531

Future work

Checklist

  • Created unit tests in tests/unit and/or in Rust for my feature if needed
  • Ran make fix to format JS and apply Clippy auto fixes
  • Made sure my code didn't add any additional warnings: make check
  • Updated documentation if needed (API.md/README.md/Other)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

src/url.rs Outdated Show resolved Hide resolved
tests/unit/http.test.ts Outdated Show resolved Hide resolved
tests/unit/http.test.ts Outdated Show resolved Hide resolved
tests/unit/http.test.ts Outdated Show resolved Hide resolved
tests/unit/http.test.ts Outdated Show resolved Hide resolved
tests/unit/http.test.ts Outdated Show resolved Hide resolved
@imaitland imaitland force-pushed the iainland/url-module-3 branch from d5ff788 to a7d86a1 Compare March 26, 2024 13:18
@imaitland imaitland force-pushed the iainland/url-module-3 branch 2 times, most recently from 827c108 to dae1db7 Compare March 26, 2024 14:39
@imaitland imaitland force-pushed the iainland/url-module-3 branch from dae1db7 to 89ff9ef Compare March 26, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants