fast-uri

NPM version CI neostandard javascript style

Dependency-free RFC 3986 URI toolbox.

Usage

Options

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:

  • 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's scheme property to determine the URI's scheme.

  • tolerant (boolean, false) If set to true, the parser will relax URI resolving rules.

  • absolutePath (boolean, false) If set to true, the serializer will not resolve a relative path component.

  • unicodeSupport (boolean, false) If set to true, the parser will unescape non-ASCII characters in the parsed output as per RFC 3987.

  • domainHost (boolean, false) If set to true, the library will treat the host component as a domain name, and convert IDNs (International Domain Names) as per RFC 5891.

Parse

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: "/one/two.three",
  query: "q1=a1&q2=a2",
  fragment: "body"
}

Serialize

Resolve

Equal

Scheme supports

fast-uri supports inserting custom scheme-dependent processing rules. Currently, fast-uri has built-in support for the following schemes:

Benchmarks

TODO

License

Licensed under BSD-3-Clause.

Last updated