Closed
Description
- Version: v11.1.0
- Platform: macOS
- Subsystem: url
When passing an invalid URL to URL
's href
setter, the original URL gets destroyed, in contrary to the spec.
> u = new URL('https://example.com/')
URL {
href: 'https://example.com/',
origin: 'https://example.com',
protocol: 'https:',
username: '',
password: '',
host: 'example.com',
hostname: 'example.com',
port: '',
pathname: '/',
search: '',
searchParams: URLSearchParams {},
hash: '' }
> u.href = ''
{ TypeError [ERR_INVALID_URL]: Invalid URL:
at onParseError (internal/url.js:240:17)
at parse (internal/url.js:249:3)
at URL.set [as href] (internal/url.js:447:7) input: '' }
> u
URL {
href: ':',
origin: 'null',
protocol: ':',
username: '',
password: '',
host: '',
hostname: '',
port: '',
pathname: '',
search: '',
searchParams: URLSearchParams {},
hash: '' }