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

URL Can contains invalid hostname #271

Closed mardiros closed 8 months ago

mardiros commented 8 months ago

Hi, coming from pydantic That redirect me to servo that redirect me here now.

The url validation specifis invalid host here I https://url.spec.whatwg.org/#host-invalid-code-point

But actually the host validation is partially implemented. A hostname can neither starts nor ends with an hyphen. But currently, this implementation says that -x is a valid hostname.

https://jsdom.github.io/whatwg-url/#url=aHR0cHM6Ly8teC8=&base=YWJvdXQ6Ymxhbms=

domenic commented 8 months ago

This is a parser, not a validator. There are many invalid parseable URLs. This is discussed in the section of the spec you linked to.