URI.\+js is an \href{http://www.ietf.org/rfc/rfc3986.txt}{\texttt{ RFC 3986}} compliant, scheme extendable URI parsing/validating/resolving library for all Java\+Script environments (browsers, Node.\+js, etc). It is also compliant with the IRI (\href{http://www.ietf.org/rfc/rfc3987.txt}{\texttt{ RFC 3987}}), IDNA (\href{http://www.ietf.org/rfc/rfc5890.txt}{\texttt{ RFC 5890}}), IPv6 Address (\href{http://www.ietf.org/rfc/rfc5952.txt}{\texttt{ RFC 5952}}), IPv6 Zone Identifier (\href{http://www.ietf.org/rfc/rfc6874.txt}{\texttt{ RFC 6874}}) specifications.

URI.\+js has an extensive test suite, and works in all (Node.\+js, web) environments. It weighs in at 6.\+4kb (gzipped, 17kb deflated).\hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31566}{}\doxysection{API}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31566}
\hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31567}{}\doxysubsection{Parsing}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31567}
\begin{DoxyVerb}URI.parse("uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body");
//returns:
//{
//  scheme : "uri",
//  userinfo : "user:pass",
//  host : "example.com",
//  port : 123,
//  path : "/one/two.three",
//  query : "q1=a1&q2=a2",
//  fragment : "body"
//}
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31568}{}\doxysubsection{Serializing}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31568}
\begin{DoxyVerb}URI.serialize({scheme : "http", host : "example.com", fragment : "footer"}) === "http://example.com/#footer"
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31569}{}\doxysubsection{Resolving}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31569}
\begin{DoxyVerb}URI.resolve("uri://a/b/c/d?q", "../../g") === "uri://a/g"
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31570}{}\doxysubsection{Normalizing}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31570}
\begin{DoxyVerb}URI.normalize("HTTP://ABC.com:80/%7Esmith/home.html") === "http://abc.com/~smith/home.html"
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31571}{}\doxysubsection{Comparison}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31571}
\begin{DoxyVerb}URI.equal("example://a/b/c/%7Bfoo%7D", "eXAMPLE://a/./b/../b/%63/%7bfoo%7d") === true
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31572}{}\doxysubsection{IP Support}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31572}
\begin{DoxyVerb}//IPv4 normalization
URI.normalize("//192.068.001.000") === "//192.68.1.0"

//IPv6 normalization
URI.normalize("//[2001:0:0DB8::0:0001]") === "//[2001:0:db8::1]"

//IPv6 zone identifier support
URI.parse("//[2001:db8::7%25en1]");
//returns:
//{
//  host : "2001:db8::7%en1"
//}
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31573}{}\doxysubsection{IRI Support}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31573}
\begin{DoxyVerb}//convert IRI to URI
URI.serialize(URI.parse("http://examplé.org/rosé")) === "http://xn--exampl-gva.org/ros%C3%A9"
//convert URI to IRI
URI.serialize(URI.parse("http://xn--exampl-gva.org/ros%C3%A9"), {iri:true}) === "http://examplé.org/rosé"
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31574}{}\doxysubsection{Options}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31574}
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\+:


\begin{DoxyItemize}
\item {\ttfamily scheme} (string)

Indicates the scheme that the URI should be treated as, overriding the URI\textquotesingle{}s normal scheme parsing behavior.
\item {\ttfamily reference} (string)

If set to {\ttfamily \char`\"{}suffix\char`\"{}}, it indicates that the URI is in the suffix format, and the validator will use the option\textquotesingle{}s {\ttfamily scheme} property to determine the URI\textquotesingle{}s scheme.
\item {\ttfamily tolerant} (boolean, false)

If set to {\ttfamily true}, the parser will relax URI resolving rules.
\item {\ttfamily absolute\+Path} (boolean, false)

If set to {\ttfamily true}, the serializer will not resolve a relative {\ttfamily path} component.
\item {\ttfamily iri} (boolean, false)

If set to {\ttfamily true}, the serializer will unescape non-\/\+ASCII characters as per \href{http://www.ietf.org/rfc/rfc3987.txt}{\texttt{ RFC 3987}}.
\item {\ttfamily unicode\+Support} (boolean, false)

If set to {\ttfamily true}, the parser will unescape non-\/\+ASCII characters in the parsed output as per \href{http://www.ietf.org/rfc/rfc3987.txt}{\texttt{ RFC 3987}}.
\item {\ttfamily domain\+Host} (boolean, false)

If set to {\ttfamily true}, the library will treat the {\ttfamily host} component as a domain name, and convert IDNs (International Domain Names) as per \href{http://www.ietf.org/rfc/rfc5891.txt}{\texttt{ RFC 5891}}.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31575}{}\doxysection{Scheme Extendable}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31575}
URI.\+js supports inserting custom \href{http://en.wikipedia.org/wiki/URI_scheme}{\texttt{ scheme}} dependent processing rules. Currently, URI.\+js has built in support for the following schemes\+:


\begin{DoxyItemize}
\item http \mbox{[}\href{http://www.ietf.org/rfc/rfc2616.txt}{\texttt{ RFC 2616}}\mbox{]}
\item https \mbox{[}\href{http://www.ietf.org/rfc/rfc2818.txt}{\texttt{ RFC 2818}}\mbox{]}
\item mailto \mbox{[}\href{http://www.ietf.org/rfc/rfc6068.txt}{\texttt{ RFC 6068}}\mbox{]}
\item urn \mbox{[}\href{http://www.ietf.org/rfc/rfc2141.txt}{\texttt{ RFC 2141}}\mbox{]}
\item urn\+:uuid \mbox{[}\href{http://www.ietf.org/rfc/rfc4122.txt}{\texttt{ RFC 4122}}\mbox{]}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31576}{}\doxysubsection{HTTP/\+HTTPS Support}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31576}
\begin{DoxyVerb}URI.equal("HTTP://ABC.COM:80", "http://abc.com/") === true
URI.equal("https://abc.com", "HTTPS://ABC.COM:443/") === true
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31577}{}\doxysubsection{WS/\+WSS Support}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31577}
\begin{DoxyVerb}URI.parse("wss://example.com/foo?bar=baz");
//returns:
//{
//  scheme : "wss",
//  host: "example.com",
//  resourceName: "/foo?bar=baz",
//  secure: true,
//}

URI.equal("WS://ABC.COM:80/chat#one", "ws://abc.com/chat") === true
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31578}{}\doxysubsection{Mailto Support}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31578}
\begin{DoxyVerb}URI.parse("mailto:alpha@example.com,bravo@example.com?subject=SUBSCRIBE&body=Sign%20me%20up!");
//returns:
//{
//  scheme : "mailto",
//  to : ["alpha@example.com", "bravo@example.com"],
//  subject : "SUBSCRIBE",
//  body : "Sign me up!"
//}

URI.serialize({
    scheme : "mailto",
    to : ["alpha@example.com"],
    subject : "REMOVE",
    body : "Please remove me",
    headers : {
        cc : "charlie@example.com"
    }
}) === "mailto:alpha@example.com?cc=charlie@example.com&subject=REMOVE&body=Please%20remove%20me"
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31579}{}\doxysubsection{URN Support}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31579}
\begin{DoxyVerb}URI.parse("urn:example:foo");
//returns:
//{
//  scheme : "urn",
//  nid : "example",
//  nss : "foo",
//}
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31580}{}\doxysubsubsection{URN UUID Support}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31580}
\begin{DoxyVerb}URI.parse("urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6");
//returns:
//{
//  scheme : "urn",
//  nid : "example",
//  uuid : "f81d4fae-7dec-11d0-a765-00a0c91e6bf6",
//}
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31581}{}\doxysection{Usage}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31581}
To load in a browser, use the following tag\+: \begin{DoxyVerb}<script type="text/javascript" src="uri-js/dist/es5/uri.all.min.js"></script>
\end{DoxyVerb}
 To load in a Common\+JS/\+Module environment, first install with npm/yarn by running on the command line\+: \begin{DoxyVerb}npm install uri-js
# OR
yarn add uri-js
\end{DoxyVerb}
 Then, in your code, load it using\+: \begin{DoxyVerb}const URI = require("uri-js");
\end{DoxyVerb}
 If you are writing your code in ES6+ (ESNEXT) or Type\+Script, you would load it using\+: \begin{DoxyVerb}import * as URI from "uri-js";
\end{DoxyVerb}
 Or you can load just what you need using named exports\+: \begin{DoxyVerb}import { parse, serialize, resolve, resolveComponents, normalize, equal, removeDotSegments, pctEncChar, pctDecChars, escapeComponent, unescapeComponent } from "uri-js";
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31582}{}\doxysection{Breaking changes}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31582}
\hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31583}{}\doxysubsection{Breaking changes from 3.\+x}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31583}
URN parsing has been completely changed to better align with the specification. Scheme is now always {\ttfamily urn}, but has two new properties\+: {\ttfamily nid} which contains the Namspace Identifier, and {\ttfamily nss} which contains the Namespace Specific String. The {\ttfamily nss} property will be removed by higher order scheme handlers, such as the UUID URN scheme handler.

The UUID of a URN can now be found in the {\ttfamily uuid} property.\hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31584}{}\doxysubsection{Breaking changes from 2.\+x}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31584}
URI validation has been removed as it was slow, exposed a vulnerabilty, and was generally not useful.\hypertarget{md_sfcode_node_modules_uri_js_README_autotoc_md31585}{}\doxysubsection{Breaking changes from 1.\+x}\label{md_sfcode_node_modules_uri_js_README_autotoc_md31585}
The {\ttfamily errors} array on parsed components is now an {\ttfamily error} string. 