Conversation
This reverts commit c5ce549.
| @@ -0,0 +1,18 @@ | |||
| const url = require('node:url'); | |||
|
|
|||
| const myURL = url.parse('https://example.com/path?query=string#hash'); | |||
There was a problem hiding this comment.
Please add a test for parsing a relative url, for example:
url.parse('/path?query=string#hash')
JakobJingleheimer
left a comment
There was a problem hiding this comment.
Generally looks good! A couple things though:
- Dynamic imports?
- I think the
var→letneeds to get removed because it can easily break user code. (Requesting changes on this)
Also, I think Steven's request is a good one.
nit: I think indentation might be inconsistent across files? (spaces vs tabs)
PS Sorry it took me a bit to get to this 😓
|
update:
|
|
@AugustinMauroy is there a deprecation for this? |
This one is for https://nodejs.org/api/deprecations.html#DEP0116, I know because it’s described in the README. But I think it can handle https://nodejs.org/api/deprecations.html#DEP0169 as well |
| const myUrl = new URL('https://example.com/some/path?page=1&format=json').toString(); | ||
| ``` | ||
|
|
||
| > **Note:** The migration of `url.format` can also be done as `` `${new URL('https://example.com/some/path?page=1&format=json')}` `` which is little bit efficienter. |
There was a problem hiding this comment.
I thought i already caught that 🤔
| @@ -0,0 +1,13 @@ | |||
| const url = require('node:url'); | |||
|
|
|||
| const myURL = new URL('/path?query=string#hash'); | |||
There was a problem hiding this comment.
This throws an error
Uncaught TypeError: Failed to construct 'URL': Invalid URL
There was a problem hiding this comment.
@AugustinMauroy This codemod is very dangerous because it will cause apps to crash at runtime.
There was a problem hiding this comment.
@styfle if you can provide a better before/after example that can be used as test that will help us to fix this issue
There was a problem hiding this comment.
How so?
@JakobJingleheimer I'm not sure how else to explain. If you run the code it will throw:

There was a problem hiding this comment.
if you can provide a better before/after example
@AugustinMauroy The before is fine. The after is wrong. It should not transform the code at all. It needs to preserve the original url.parse('/path?query=string#hash')
|
@AugustinMauroy FYI: there were some undocumented pieces to a recent related deprecation (DEP0169) that may affect this: nodejs/node#61644 |
Description
Add codemod for
node:urllegacy object to whatWG urlRelated issue
close #92