GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — url: expose the WHATWG URL API globally by targos · Pull Request #18281 · nodejs/node

Conversation

@targos

@targos targos commented Jan 21, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Install URL and URLSearchParams on the global object, like they can be
found in browser environments.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

url

/cc @nodejs/tsc @nodejs/url @jasnell

Quick CI: https://ci.nodejs.org/job/node-test-pull-request-lite/106/
Quick CI: https://ci.nodejs.org/job/node-test-pull-request-lite/107/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

watilde, apapirovski, domenic, BridgeAR, bricss, mcsky, CedX, tzi, and styfle reacted with thumbs up emoji ikokostya reacted with thumbs down emoji matthewp, othree, and styfle reacted with hooray emoji chicoxyzzy reacted with confused emoji bricss, matthewp, and marcoscaceres reacted with heart emoji
All reactions
  • 👍 9 reactions
  • 👎 1 reaction
  • 🎉 3 reactions
  • 😕 1 reaction
  • ❤️ 3 reactions
@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs involving general changes in the lib/ or src/ directories. label Jan 21, 2018
@targos targos added whatwg-url Issues and PRs related to the WHATWG URL implementation. and removed lib / src Issues and PRs involving general changes in the lib/ or src/ directories. labels Jan 21, 2018
@vkurchatkin

vkurchatkin commented Jan 21, 2018

Copy link
Copy Markdown
Contributor

I'm -0 on this, but I think that it's a leat preferable to schedule this for a major release.

chicoxyzzy reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos targos added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jan 21, 2018
@targos

targos commented Jan 21, 2018

Copy link
Copy Markdown
Member Author

I think that it's a leat preferable to schedule this for a major release.

I agree. I forgot to put the semver-major label.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Jan 21, 2018

Copy link
Copy Markdown
Contributor

I'd rather not add more globals, but I won't block this if people think it's the right thing to do.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

apapirovski
apapirovski approved these changes Jan 21, 2018
View reviewed changes

@apapirovski apapirovski left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Makes complete sense to me. Very much in favour. 👍

(Even though with this being semver-major, my vote doesn't make much of a difference.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
addaleax
addaleax approved these changes Jan 21, 2018
View reviewed changes

@addaleax addaleax left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think we might want a lint rule like the one we have for Buffer which verifies that internal modules don’t rely on the global and instead do explicitly require url?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@targos

targos commented Jan 21, 2018

Copy link
Copy Markdown
Member Author

@addaleax we don't need a special rule. ESLint already considers uses of global URL an error.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

watilde
watilde approved these changes Jan 21, 2018
View reviewed changes
@mcollina

mcollina commented Jan 21, 2018

Copy link
Copy Markdown
Member

I'm +0 on this. The implementation is ok, but I would not add more globals, but I'm not objecting either as it's very common on web platform.

If we are doing this, I would prefer if we started using it everywhere, even internally (https://github.com/nodejs/node/blob/master/lib/_http_client.js#L26), and gently phase away the old url parser. If we think this is the way to go, there is very little incentive for the community to adopt it if we do not use it internally.

davesag and styfle reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

TimothyGu
TimothyGu approved these changes Jan 21, 2018
View reviewed changes

@TimothyGu TimothyGu left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

🎉

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
BridgeAR
BridgeAR approved these changes Jan 22, 2018
View reviewed changes
joyeecheung
joyeecheung approved these changes Jan 22, 2018
View reviewed changes
bnoordhuis
bnoordhuis approved these changes Jan 22, 2018
View reviewed changes

@bnoordhuis bnoordhuis left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I personally don't have a problem with exposing them as globals. Next up: TextEncoder?

I'll get my coat.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
evanlucas
evanlucas approved these changes Jan 22, 2018
View reviewed changes
Comment thread doc/api/url.md Outdated

@evanlucas evanlucas Jan 22, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

we should be able to also set this, shouldn't we?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread doc/api/url.md Outdated

@evanlucas evanlucas Jan 22, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

we should be able to go ahead and set this, no?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@targos targos Jan 22, 2018

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

thanks. updated

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@targos
targos force-pushed the global-url branch from 68c5b6a to 61cda62 Compare January 22, 2018 14:48
@targos

targos commented Jan 22, 2018

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/12656/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Jan 22, 2018
View reviewed changes

@jasnell jasnell left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Very happy to see this come back around. It wasn't quite as popular an idea the first time I suggested it :-)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ChALkeR

ChALkeR commented Jan 22, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

-0 for reasons described in nodejs/node-eps#28 (comment) (my and others comments). I don't think that things changed much since that discussion.

I won't block this though if this is what others want.

chicoxyzzy reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

silverwind
silverwind reviewed Jan 22, 2018
View reviewed changes
Comment thread lib/internal/bootstrap_node.js Outdated

@silverwind silverwind Jan 22, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Does this impact startup performance, and if so, could it be required on use possibly?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@TimothyGu TimothyGu Jan 22, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

No, as this module is already being imported on startup:

node/lib/internal/bootstrap_node.js

Lines 80 to 82 in a3555d0

// Ensure setURLConstructor() is called before the native
// URL::ToObject() method is used.
NativeModule.require('internal/url');

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

silverwind and dotcypress reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@maclover7
maclover7 force-pushed the master branch from bb5575a to 993b716 Compare January 26, 2018 22:02
@cjihrig
cjihrig force-pushed the master branch from 993b716 to 082f952 Compare January 26, 2018 22:36
@targos
url: expose the WHATWG URL API globally
b7693a7
Install URL and URLSearchParams on the global object, like they can be
found in browser environments.

PR-URL: nodejs#18281
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@targos
targos force-pushed the global-url branch from 61cda62 to b7693a7 Compare January 29, 2018 09:23
@targos

targos commented Jan 29, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

New CI: https://ci.nodejs.org/job/node-test-pull-request/12797/
Edit: AIX rebuild: https://ci.nodejs.org/job/node-test-commit-aix/12156/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos

targos commented Jan 30, 2018

Copy link
Copy Markdown
Member Author

I'm not sure what's going on with AIX but it does not seem related.
Given all the +1s, I'm going to land this tomorrow if there are no explicit objections.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Jan 30, 2018

Copy link
Copy Markdown
Member

Trying again on AIX. Given all the problems that have erupted on CI in the last month or two, I'm kinda -1 on landing something if we can't get CI to build/run on a platform. But I'm optimistic this is fixed now, so hopefully no problems...

CI for AIX: https://ci.nodejs.org/job/node-test-commit-aix/12189/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mhdawson

mhdawson commented Jan 31, 2018

Copy link
Copy Markdown
Member

@Trott thanks for restarting AIX. I fixed up one of the machines yesterday. There were a bunch of stale processes. I see the run you launched is green :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos targos added the notable-change PRs with changes that should be highlighted in changelogs. label Jan 31, 2018
@targos

targos commented Jan 31, 2018

Copy link
Copy Markdown
Member Author

Landed in 3124146

styfle reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos targos closed this Jan 31, 2018
@targos
targos deleted the global-url branch January 31, 2018 15:08
targos added a commit that referenced this pull request Jan 31, 2018
@targos
url: expose the WHATWG URL API globally
3124146
Install URL and URLSearchParams on the global object, like they can be
found in browser environments.

PR-URL: #18281
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@fregante

fregante commented Feb 2, 2018

Copy link
Copy Markdown

I'm a nobody here, but I hope to see APIs shared across platform in the global scope so I don't have to mess with the browser field and "redirect" files every time I want to publish a cross-platform package.

styfle reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jdalton jdalton mentioned this pull request Mar 15, 2018
module: add createRequireFunction method #19360
Closed
4 tasks done
@guybedford

guybedford commented Apr 24, 2018

Copy link
Copy Markdown
Contributor

I'm just wondering, would it be worth backporting this to 8.x? Would help a lot to be able to treat this as a baseline support. I can put together the port if it sounds like it could be possible.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thom4parisot thom4parisot mentioned this pull request Apr 24, 2018
The WHATWG URL API is now a global. thom4parisot/nodebook#271
Closed
@TimothyGu

TimothyGu commented Apr 24, 2018

Copy link
Copy Markdown
Member

@guybedford I'd rather not since there might be code out there checking typeof URL to detect Node.js/browsers.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@guybedford

guybedford commented Apr 25, 2018

Copy link
Copy Markdown
Contributor

@TimothyGu I've never ever seen a pattern like that for environment detection - usually it is based on Window or Document. Every case I've seen doing typeof URL is for a feature detection to use URL, which will imply a behaviour change yes, but it should be a wanted one in those cases.

Users wanting to use the URL global in Node won't be able to until Node 8 EOL, which is over a year away, so it's a shame not to be able to really use this awesome feature in published packages that want to support Node 8 +.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Apr 25, 2018

Copy link
Copy Markdown
Member

I'm generically -1 in adding new globals in semver-minors. Code running without 'use strict' will be affected (sigh): unfortunately there are plenty of modules that do exactly that.
I think landing it in 8 will require a @nodejs/tsc vote. It might be a good thing to check anyway what our position is, if you want to move this forward and champion this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos

targos commented Apr 25, 2018

Copy link
Copy Markdown
Member Author

If you feel strongly about it, can you please open a new issue for that discussion?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

guybedford pushed a commit to guybedford/node that referenced this pull request Apr 25, 2018
@targos @guybedford
url: expose the WHATWG URL API globally
df281f2
Install URL and URLSearchParams on the global object, like they can be
found in browser environments.

PR-URL: nodejs#18281
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@guybedford guybedford mentioned this pull request Apr 25, 2018
[v8.x backport] url: expose the WHATWG URL API globally #20306
Closed
@guybedford

guybedford commented Apr 25, 2018

Copy link
Copy Markdown
Contributor

I've created #20306 to track. @mcollina what sort of code examples without 'use strict' might be affected by this do you think?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented May 2, 2018

Copy link
Copy Markdown
Member
try {
  new URL("http://google.com")
} catch (e) {
  // we are on Node 10!
  // so we can use XYZ.
}

also

if (!global.URL) {
  // assume something that's not true anymore 
}
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
@targos @MayaLekova
url: expose the WHATWG URL API globally
6be79f6
Install URL and URLSearchParams on the global object, like they can be
found in browser environments.

PR-URL: nodejs#18281
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@skyclouds2001 skyclouds2001 mentioned this pull request Nov 11, 2024
Update Node.js data for URLSearchParams mdn/browser-compat-data#24998
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bnoordhuis bnoordhuis bnoordhuis approved these changes
@jasnell jasnell jasnell approved these changes
@addaleax addaleax addaleax approved these changes
@watilde watilde watilde approved these changes
@joyeecheung joyeecheung joyeecheung approved these changes
@BridgeAR BridgeAR BridgeAR approved these changes
+4 more reviewers
@silverwind silverwind silverwind left review comments
@TimothyGu TimothyGu TimothyGu approved these changes
@apapirovski apapirovski apapirovski approved these changes
@evanlucas evanlucas evanlucas approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

notable-change PRs with changes that should be highlighted in changelogs. semver-major PRs that contain breaking changes and should be released in the next major version. whatwg-url Issues and PRs related to the WHATWG URL implementation.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

20 participants

@targos @vkurchatkin @cjihrig @mcollina @ChALkeR @Trott @mhdawson @fregante @guybedford @TimothyGu @apapirovski @silverwind @bnoordhuis @jasnell @evanlucas @addaleax @watilde @joyeecheung @BridgeAR @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.