URL
decodes searchParams
:
> [...new URL('http://localhost?foo%40=bar').searchParams][0]
['foo@', 'bar']
Yet for some reason, it doesn’t decode username
/password
:
> new URL('http://jimbo%40gmail.com:%40wesome@localhost').username
'jimbo%40gmail.com'
> new URL('http://jimbo%40gmail.com:%40wesome@localhost').password
'%40wesome'
Obviously I know how to work around this, but does anyone know the reason why it doesn’t decode them?
RFC 3986 section 3.2.1 specifically indicates that the username
/password
of a URI may be percent-encoded:
userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
So I would assume this is a bug if it were not a well-standardized API.