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

feat(node): Add missing url.parse #1667

Merged
merged 9 commits into from
Dec 7, 2021

Conversation

getspooky
Copy link
Contributor

Ref #1666

node/url.ts Outdated
}
}

const self = new URL(url);
Copy link
Member

Choose a reason for hiding this comment

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

I think url.parse should return url.Url object, not a global URL object

You can check it in Node.js repl like the below

> url.parse("https://example.com") instanceof url.Url
true
> url.parse("https://example.com") instanceof URL
false

node/url.ts Outdated
Comment on lines 465 to 466
self.href = format(self);
}
Copy link
Member

Choose a reason for hiding this comment

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

You forgot returning self?

@kt3k
Copy link
Member

kt3k commented Dec 2, 2021

@getspooky
Can you also enable some of native node.js test cases? The instruction for doing it is available in node/README.md

@getspooky
Copy link
Contributor Author

@kt3k fixed , Now parse return url.Url object, not a global URL object.

Deno:

test [url] URL ...Url {
  protocol: "http:",
  slashes: true,
  auth: null,
  host: "github.com",
  port: null,
  hostname: "github.com",
  hash: null,
  search: null,
  query: null,
  pathname: "/",
  path: "/",
  href: "http://github.com/"
}

Node:

> url.parse("http://github.com")
Url {
  protocol: 'http:',
  slashes: true,
  auth: null,
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: '/',
  path: '/',
  href: 'http://github.com/'
}

@kt3k
Copy link
Member

kt3k commented Dec 3, 2021

@getspooky

fixed , Now parse return url.Url object, not a global URL object.

Thanks for updating! The change looks good to me, but the test file test-url-parse-format.js is not added to the source tree. Please remove test-url-parse-format.js from ignore part of node/_tools/config.json first, then run node/_tools/setup.ts, which should copy the actual test file under node/_tools/suites/

@getspooky
Copy link
Contributor Author

@kt3k done

@wafuwafu13
Copy link
Contributor

wafuwafu13 commented Dec 4, 2021

@getspooky

https://github.com/denoland/deno_std/runs/4410914506?check_suite_focus=true

AssertionError: Failed assertion: error: Uncaught TypeError: common.skip is not a function

We haven't implemented hasIntl yet, so it would be nice to comment it out like this.

@getspooky getspooky requested a review from kt3k December 4, 2021 20:36
@kt3k
Copy link
Member

kt3k commented Dec 5, 2021

test-url-parse-format.js is not passing in mac and ubuntu (See the CI logs

The assertion at line 985 seems failing. Maybe let's comment out it as well with a TODO comment.

Also now you modified test-url-parse-format.js. So now you need to add test-url-parse-format.js to ignore part of config.json

@getspooky
Copy link
Contributor Author

@kt3k fixed

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

@getspooky LGTM. Thank you for your contribution!

url.format tests are still remaining, but this adds very accurate compatibility of url.parse. Nice work!

@kt3k kt3k merged commit f03767e into denoland:main Dec 7, 2021
@kt3k kt3k mentioned this pull request Dec 7, 2021
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.

3 participants