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

Add URL #1359

Merged
merged 1 commit into from
Dec 18, 2018
Merged

Add URL #1359

merged 1 commit into from
Dec 18, 2018

Conversation

kitsonk
Copy link
Contributor

@kitsonk kitsonk commented Dec 17, 2018

Fixes part of: #1047

This PR adds the URL global object which makes it easier to parse URL and work with their parts. The code tries to functionally replicate the Web Standard but doesn't follow the logic of the standard (which has a lot of obtuse and obscure logic in the IDL).

@LinusU
Copy link
Contributor

LinusU commented Dec 17, 2018

What do you think about adding the following test, which passes in Safari 12.0.2 and Node.js 11.1.0, but which I think will fail here since the value of hash is encodeURIComponent-ed on the way in, but not decoded on the way out.

test(function urlBaseString() {
  const url = new URL("http:https://example.com");
  url.hash = "%test";
  assertEqual(url.hash, "#%test");
  url.hash = url.hash;
  assertEqual(url.hash, "#%test");
});

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

A clean new URL implementation - awesome! Looks good - but please add the test @LinusU suggests.

];

function parse(url: string): URLParts | undefined {
const urlMatch = urlRegExp.exec(url);
Copy link
Member

Choose a reason for hiding this comment

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

Do other URL implementations use RegExp?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Node.js uses a combination of splitting strings and regular expressions. It's url is a slightly different beast to the the whatwg URL. JSDom follows the IDL pedantically, so it ingests each character and does loads of branching. While it complies 100% including the logic, it is a lot of code. There are two other polyfills that I found on npm, one ingests per char, the other uses regular expressions.

@kitsonk
Copy link
Contributor Author

kitsonk commented Dec 17, 2018

@LinusU thanks for the heads up. I also found a couple issues with the .pathname setter as well.

js/url.ts Outdated Show resolved Hide resolved
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM

@ry ry merged commit 91a41ca into denoland:master Dec 18, 2018
ry added a commit to ry/deno that referenced this pull request Dec 23, 2018
- Upgrade V8 to 7.2.502.16 (denoland#1403)
- Remove support for extensionless import  (denoland#1396)
- make stdout unbuffered (denoland#1355)
- Implement `Body.formData` for fetch (denoland#1393)
- Improve handling of non-coercable objects in assertEqual (denoland#1385)
- Avoid fetch segfault on empty Uri (denoland#1394)
- Expose deno.inspect (denoland#1378)
- "cargo build" support (denoland#1369 denoland#1296 denoland#1377 denoland#1379)
- Add illegal header name and value guards (denoland#1375)
- Fix URLSearchParams set() and constructor() (denoland#1368)
- Remove prebuilt v8 support (denoland#1369)
- Enable jumbo build in release. (denoland#1362)
- Add URL implementation (denoland#1359)
- Add console.count and console.time (denoland#1358)
@ry ry mentioned this pull request Dec 23, 2018
ry added a commit to ry/deno that referenced this pull request Dec 23, 2018
- Upgrade V8 to 7.2.502.16 (denoland#1403)
- Remove support for extensionless import  (denoland#1396)
- make stdout unbuffered (denoland#1355)
- Implement `Body.formData` for fetch (denoland#1393)
- Improve handling of non-coercable objects in assertEqual (denoland#1385)
- Avoid fetch segfault on empty Uri (denoland#1394)
- Expose deno.inspect (denoland#1378)
- "cargo build" support (denoland#1369 denoland#1296 denoland#1377 denoland#1379)
- Add illegal header name and value guards (denoland#1375)
- Fix URLSearchParams set() and constructor() (denoland#1368)
- Remove prebuilt v8 support (denoland#1369)
- Enable jumbo build in release. (denoland#1362)
- Add URL implementation (denoland#1359)
- Add console.count and console.time (denoland#1358)
ry added a commit to ry/deno that referenced this pull request Dec 23, 2018
- Upgrade V8 to 7.2.502.16 (denoland#1403)
- Remove support for extensionless import  (denoland#1396)
- make stdout unbuffered (denoland#1355)
- Implement `Body.formData` for fetch (denoland#1393)
- Improve handling of non-coercable objects in assertEqual (denoland#1385)
- Avoid fetch segfault on empty Uri (denoland#1394)
- Expose deno.inspect (denoland#1378)
- "cargo build" support (denoland#1369 denoland#1296 denoland#1377 denoland#1379)
- Add illegal header name and value guards (denoland#1375)
- Fix URLSearchParams set() and constructor() (denoland#1368)
- Remove prebuilt v8 support (denoland#1369)
- Enable jumbo build in release. (denoland#1362)
- Add URL implementation (denoland#1359)
- Add console.count and console.time (denoland#1358)
ry added a commit to ry/deno that referenced this pull request Dec 23, 2018
- Upgrade V8 to 7.2.502.16 (denoland#1403)
- Remove support for extensionless import  (denoland#1396)
- make stdout unbuffered (denoland#1355)
- Implement `Body.formData` for fetch (denoland#1393)
- Improve handling of non-coercable objects in assertEqual (denoland#1385)
- Avoid fetch segfault on empty Uri (denoland#1394)
- Expose deno.inspect (denoland#1378)
- "cargo build" support (denoland#1369 denoland#1296 denoland#1377 denoland#1379)
- Add illegal header name and value guards (denoland#1375)
- Fix URLSearchParams set() and constructor() (denoland#1368)
- Remove prebuilt v8 support (denoland#1369)
- Enable jumbo build in release. (denoland#1362)
- Add URL implementation (denoland#1359)
- Add console.count and console.time (denoland#1358)
ry added a commit to ry/deno that referenced this pull request Dec 24, 2018
- Upgrade V8 to 7.2.502.16 (denoland#1403)
- Remove support for extensionless import  (denoland#1396)
- make stdout unbuffered (denoland#1355)
- Implement `Body.formData` for fetch (denoland#1393)
- Improve handling of non-coercable objects in assertEqual (denoland#1385)
- Avoid fetch segfault on empty Uri (denoland#1394)
- Expose deno.inspect (denoland#1378)
- "cargo build" support (denoland#1369 denoland#1296 denoland#1377 denoland#1379)
- Add illegal header name and value guards (denoland#1375)
- Fix URLSearchParams set() and constructor() (denoland#1368)
- Remove prebuilt v8 support (denoland#1369)
- Enable jumbo build in release. (denoland#1362)
- Add URL implementation (denoland#1359)
- Add console.count and console.time (denoland#1358)
ry added a commit to ry/deno that referenced this pull request Dec 24, 2018
- "cargo build" support (denoland#1369 denoland#1296 denoland#1377 denoland#1379)
- Remove support for extensionless import (denoland#1396)
- Upgrade V8 to 7.2.502.16 (denoland#1403)
- make stdout unbuffered (denoland#1355)
- Implement `Body.formData` for fetch (denoland#1393)
- Improve handling of non-coercable objects in assertEqual (denoland#1385)
- Avoid fetch segfault on empty Uri (denoland#1394)
- Expose deno.inspect (denoland#1378)
- Add illegal header name and value guards (denoland#1375)
- Fix URLSearchParams set() and constructor() (denoland#1368)
- Remove prebuilt v8 support (denoland#1369)
- Enable jumbo build in release. (denoland#1362)
- Add URL implementation (denoland#1359)
- Add console.count and console.time (denoland#1358)
- runtime arg check `URLSearchParams` (denoland#1390)
ry added a commit to ry/deno that referenced this pull request Dec 24, 2018
- "cargo build" support (denoland#1369 denoland#1296 denoland#1377 denoland#1379)
- Remove support for extensionless import (denoland#1396)
- Upgrade V8 to 7.2.502.16 (denoland#1403)
- make stdout unbuffered (denoland#1355)
- Implement `Body.formData` for fetch (denoland#1393)
- Improve handling of non-coercable objects in assertEqual (denoland#1385)
- Avoid fetch segfault on empty Uri (denoland#1394)
- Expose deno.inspect (denoland#1378)
- Add illegal header name and value guards (denoland#1375)
- Fix URLSearchParams set() and constructor() (denoland#1368)
- Remove prebuilt v8 support (denoland#1369)
- Enable jumbo build in release. (denoland#1362)
- Add URL implementation (denoland#1359)
- Add console.count and console.time (denoland#1358)
- runtime arg check `URLSearchParams` (denoland#1390)
ry added a commit that referenced this pull request Dec 24, 2018
- "cargo build" support (#1369 #1296 #1377 #1379)
- Remove support for extensionless import (#1396)
- Upgrade V8 to 7.2.502.16 (#1403)
- make stdout unbuffered (#1355)
- Implement `Body.formData` for fetch (#1393)
- Improve handling of non-coercable objects in assertEqual (#1385)
- Avoid fetch segfault on empty Uri (#1394)
- Expose deno.inspect (#1378)
- Add illegal header name and value guards (#1375)
- Fix URLSearchParams set() and constructor() (#1368)
- Remove prebuilt v8 support (#1369)
- Enable jumbo build in release. (#1362)
- Add URL implementation (#1359)
- Add console.count and console.time (#1358)
- runtime arg check `URLSearchParams` (#1390)
@kitsonk kitsonk deleted the url branch August 2, 2022 04: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.

None yet

4 participants