require('url').parse('someurl.com/page')
have been docs-only deprecated, and our strict linter is unhappy about it... I have tried to replace it in our code with what the internet suggests new URL('someurl.com/page')
which works in most cases.
However, we have examples where the url is a local image some/image.png
and that was working nicely with url.parse() and returns:
Url {
protocol: null,
slashes: null,
auth: null,
host: null,
port: null,
hostname: null,
hash: null,
search: null,
query: null,
pathname: '/some/image.png',
path: '/some/image.png',
href: '/some/image.png'
}
But the suggested replacement new URL('some/image.png')
throws a type error...
TypeError [ERR_INVALID_URL] [ERR_INVALID_URL]: Invalid URL: /some/image.png
url.parse is doing some validation and accept local paths, but the new url constructor does not. What to do ?