Closed zaidoonhad closed 1 year ago
Hey there,
new URI
does not parse the URL beyond figuring out the distinct parts (path, query, fragment, …) and does not mutate the URL itself.
.path
mutates the URL and therefore takes a much closer look at the value. it first decodes the input, then encodes it to make sure we're producing a valid URL.
url.path()
// '/something/%E3%82%BF%E3%82%B0/%E6%88%A6%E'
url.segment()
// ['something', '%E3%82%BF%E3%82%B0', '%E6%88%A6%E']
decodeURIComponent('%E3%82%BF%E3%82%B0')
// 'タグ'
decodeURIComponent('%E6%88%A6%E')
// Uncaught URIError: URI malformed
The problem is the trailing %E
, which is not a valid percent-encoding-sequence - it's missing a character.
Repro
path
/pathname
doesn't like the encoding here butURI(xxx)
was successfully able to parse the url . So I would expect for it work when trying to override part of the path as well.