Now that url.parse is deprecated in Node.js, how do people go about parsing urls that are not fully qualified, e.g. `/foo?bar=baz` from `req.url`. Do you still use it and ignore that it's deprecated, use a user-land module instead, or something else?
-
-
Replying to @wa7son
I'm legit curious about this because this is one of the methods I've been thinking about how to port to Rust recently. url.parse() is so important for practical reasons.
1 reply 0 retweets 3 likes -
Replying to @yoshuawuyts
Previously I've just ignored that it was deprecated and used it for these use-cases anyway. But now that
@StandardJS v13 has been released, the linter complains that I'm using a deprecated API. I can of course add `// eslint-disable-line node/no-deprecated-api` everywhere
1 reply 0 retweets 1 like -
new URL('/foo', 'http://localhost');
3 replies 2 retweets 17 likes -
Replying to @trygve_lie @wa7son and
Or in your case; new URL(req.url, 'http://localhost'). If req.url is fully resolved second argument is ignored, if not fully resolved it will use the second argument.
1 reply 0 retweets 4 likes
oh dope, so no more `if (isUrl(arg)) {} else {}` checks. That's very neat!
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.