Dependency-free RFC 3986 URI toolbox.
All of the above functions can accept an additional options argument that is an object that can contain one or more of the following properties:
Malformed authorities and out-of-range ports are reported through the parsed component's error field. normalize() leaves malformed string inputs unchanged, and equal() returns false when either string input is malformed.
-
scheme(string) Indicates the scheme that the URI should be treated as, overriding the URI's normal scheme parsing behavior. -
reference(string) If set to"suffix", it indicates that the URI is in the suffix format and the parser will use the option'sschemeproperty to determine the URI's scheme. -
tolerant(boolean, false) If set totrue, the parser will relax URI resolving rules. -
absolutePath(boolean, false) If set totrue, the serializer will not resolve a relativepathcomponent. -
unicodeSupport(boolean, false) If set totrue, the parser will unescape non-ASCII characters in the parsed output as per RFC 3987. -
domainHost(boolean, false) If set totrue, the library will treat thehostcomponent as a domain name, and convert IDNs (International Domain Names) as per RFC 5891.
const uri = require('fast-uri')
uri.parse('uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body')
// Output
{
scheme: "uri",
userinfo: "user:pass",
host: "example.com",
port: 123,
path: