jsdom / whatwg-url

An implementation of the WHATWG URL Standard in JavaScript
https://jsdom.github.io/whatwg-url/
MIT License
371 stars 94 forks source link

but parsing URL with IPv4 address as hostname? #270

Closed derhuerst closed 8 months ago

derhuerst commented 8 months ago
mkdir bug
cd bug
npm init --yes
npm i whatwg-url@14
npm ls
# bug@1.0.0 /Users/j/playground/bug
# └── whatwg-url@14.0.0
node
> const {parseURL} = await import('whatwg-url')
> parseURL('http://10.128.32.61:17000/').host
// 176169021

This also happens with whatwg-url@13.0.0 btw.

domenic commented 8 months ago

This is as expected when using the low-level parseURL API and inspecting the internal URL record data structure. If you want to serialize the host back to a string, use serializeHost.

Or, just use the high-level API.