| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
## Why this PR ? Currently, the URL docs for the WHATWG URL spec support are somewhat lacking in their code example of how to access the new URL constructor that lives inside the core url package. ## Suggested change Improve the code example that shows how the new URL constructor should be accessed to begin with.
|
If we want to promote accessing the new WHATWG URL from the global scope then maybe the code example as-is is ok, but otherwise, since this is a docs for the core URL module then it is somewhat confusing how to access since doing this won't work: const URL = require('url')
const myURL = new URL('..') |
Sorry, something went wrong.
|
@lirantal Yeah, since all supported Node.js versions have URL on the global object, I’d not document require('url').URL as the default way to access the URL constructor. Maybe the Class: `URL` section could mention that this is an alternative way of accessing the class? |
Sorry, something went wrong.
|
Exactly, so it depends what we want to promote :-) |
Sorry, something went wrong.
|
@lirantal Since nobody else has weighed in here yet: I’d say let’s not do this, and instead mention this as an alternative possibility for access in the URL constructor’s documentation section. |
Sorry, something went wrong.
|
Sure. So would we replace this one https://github.com/nodejs/node/pull/32782/files#diff-dd182d238def46a3af0d112f617e8838L104 with the option I suggested or just add it as a note below it? I need an actual code example would be good. |
Sorry, something went wrong.
| Parsing the URL string using the WHATWG API: | ||
|
|
||
| ```js | ||
| const URL = require('url').URL |
There was a problem hiding this comment.
Now that URL is global, this is not strictly required. This might be improved by explaining that distinction?
Sorry, something went wrong.
There was a problem hiding this comment.
I know it works global :)
I'm thinking out loud in this PR whether we want to promote that or not and yes to make one or the other more explicit so devs are aware.
Sorry, something went wrong.
|
@lirantal I think an explicit second example would be good. E.g.:
|
Sorry, something went wrong.
|
@addaleax added it to the constructor example instead of the generic one on the intro. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM with the linter failure fixed (should be ```js)
Sorry, something went wrong.
|
all fixed up 👍 |
Sorry, something went wrong.
|
CI fails on Build from tarball / test-tarball-windows (pull_request) Failing after 51m — test-tarball-windows here: https://github.com/nodejs/node/actions/runs/87457793 |
Sorry, something went wrong.
Currently, the URL docs for the WHATWG URL spec support are somewhat lacking in their code example of how to access the new URL constructor that lives inside the core url package. PR-URL: #32782 Reviewed-By: Anna Henningsen <anna@addaleax.net>
|
Thanks Anna 👍 |
Sorry, something went wrong.
Currently, the URL docs for the WHATWG URL spec support are somewhat lacking in their code example of how to access the new URL constructor that lives inside the core url package. PR-URL: #32782 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Currently, the URL docs for the WHATWG URL spec support are somewhat lacking in their code example of how to access the new URL constructor that lives inside the core url package. PR-URL: #32782 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Currently, the URL docs for the WHATWG URL spec support are somewhat lacking in their code example of how to access the new URL constructor that lives inside the core url package. PR-URL: #32782 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Currently, the URL docs for the WHATWG URL spec support are somewhat lacking in their code example of how to access the new URL constructor that lives inside the core url package. PR-URL: #32782 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Currently, the URL docs for the WHATWG URL spec support are somewhat lacking in their code example of how to access the new URL constructor that lives inside the core url package. PR-URL: #32782 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Currently, the URL docs for the WHATWG URL spec support are somewhat lacking in their code example of how to access the new URL constructor that lives inside the core url package. PR-URL: #32782 Reviewed-By: Anna Henningsen <anna@addaleax.net>
| Back | FazBrowse Home | New Git URL |
Why this PR ?
Currently, the URL docs for the WHATWG URL spec support are
somewhat lacking in their code example of how to access the
new URL constructor that lives inside the core url package.
Suggested change
Improve the code example that shows how the new URL
constructor should be accessed to begin with.
Checklist