whatwg-\/url is a full implementation of the WHATWG \href{https://url.spec.whatwg.org/}{\texttt{ URL Standard}}. It can be used standalone, but it also exposes a lot of the internal algorithms that are useful for integrating a URL parser into a project like \href{https://github.com/jsdom/jsdom}{\texttt{ jsdom}}.\hypertarget{md_sfcode_node_modules_whatwg_url_README_autotoc_md34034}{}\doxysection{Specification conformance}\label{md_sfcode_node_modules_whatwg_url_README_autotoc_md34034}
whatwg-\/url is currently up to date with the URL spec up to commit \href{https://github.com/whatwg/url/commit/a19495e27ad95154543b46f751d1a1bf25553808}{\texttt{ a19495e}}.

For {\ttfamily file\+:} URLs, whose \href{https://url.spec.whatwg.org/\#concept-url-origin}{\texttt{ origin is left unspecified}}, whatwg-\/url chooses to use a new opaque origin (which serializes to {\ttfamily \char`\"{}null\char`\"{}}).\hypertarget{md_sfcode_node_modules_whatwg_url_README_autotoc_md34035}{}\doxysection{API}\label{md_sfcode_node_modules_whatwg_url_README_autotoc_md34035}
\hypertarget{md_sfcode_node_modules_whatwg_url_README_autotoc_md34036}{}\doxysubsection{The $<$tt$>$\+URL$<$/tt$>$ and $<$tt$>$\+URLSearch\+Params$<$/tt$>$ classes}\label{md_sfcode_node_modules_whatwg_url_README_autotoc_md34036}
The main API is provided by the \href{https://url.spec.whatwg.org/\#url-class}{\texttt{ {\ttfamily URL}}} and \href{https://url.spec.whatwg.org/\#interface-urlsearchparams}{\texttt{ {\ttfamily URLSearch\+Params}}} exports, which follows the spec\textquotesingle{}s behavior in all ways (including e.\+g. {\ttfamily USVString} conversion). Most consumers of this library will want to use these.\hypertarget{md_sfcode_node_modules_whatwg_url_README_autotoc_md34037}{}\doxysubsection{Low-\/level URL Standard API}\label{md_sfcode_node_modules_whatwg_url_README_autotoc_md34037}
The following methods are exported for use by places like jsdom that need to implement things like \href{https://html.spec.whatwg.org/\#htmlhyperlinkelementutils}{\texttt{ {\ttfamily HTMLHyperlink\+Element\+Utils}}}. They mostly operate on or return an \char`\"{}internal URL\char`\"{} or \href{https://url.spec.whatwg.org/\#concept-url}{\texttt{ \char`\"{}\+URL record\char`\"{}}} type.


\begin{DoxyItemize}
\item \href{https://url.spec.whatwg.org/\#concept-url-parser}{\texttt{ URL parser}}\+: {\ttfamily parse\+URL(input, \{ base\+URL, encoding\+Override \})}
\item \href{https://url.spec.whatwg.org/\#concept-basic-url-parser}{\texttt{ Basic URL parser}}\+: {\ttfamily basic\+URLParse(input, \{ base\+URL, encoding\+Override, url, state\+Override \})}
\item \href{https://url.spec.whatwg.org/\#concept-url-serializer}{\texttt{ URL serializer}}\+: {\ttfamily serialize\+URL(url\+Record, exclude\+Fragment)}
\item \href{https://url.spec.whatwg.org/\#concept-host-serializer}{\texttt{ Host serializer}}\+: {\ttfamily serialize\+Host(host\+From\+URLRecord)}
\item \href{https://url.spec.whatwg.org/\#serialize-an-integer}{\texttt{ Serialize an integer}}\+: {\ttfamily serialize\+Integer(number)}
\item \href{https://url.spec.whatwg.org/\#concept-url-origin}{\texttt{ Origin}} \href{https://html.spec.whatwg.org/multipage/origin.html\#ascii-serialisation-of-an-origin}{\texttt{ serializer}}\+: {\ttfamily serialize\+URLOrigin(url\+Record)}
\item \href{https://url.spec.whatwg.org/\#set-the-username}{\texttt{ Set the username}}\+: {\ttfamily set\+The\+Username(url\+Record, username\+String)}
\item \href{https://url.spec.whatwg.org/\#set-the-password}{\texttt{ Set the password}}\+: {\ttfamily set\+The\+Password(url\+Record, password\+String)}
\item \href{https://url.spec.whatwg.org/\#cannot-have-a-username-password-port}{\texttt{ Cannot have a username/password/port}}\+: {\ttfamily cannot\+Have\+AUsername\+Password\+Port(url\+Record)}
\item \href{https://url.spec.whatwg.org/\#percent-decode}{\texttt{ Percent decode}}\+: {\ttfamily percent\+Decode(buffer)}
\end{DoxyItemize}

The {\ttfamily state\+Override} parameter is one of the following strings\+:


\begin{DoxyItemize}
\item \href{https://url.spec.whatwg.org/\#scheme-start-state}{\texttt{ {\ttfamily \char`\"{}scheme start\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#scheme-state}{\texttt{ {\ttfamily \char`\"{}scheme\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#no-scheme-state}{\texttt{ {\ttfamily \char`\"{}no scheme\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#special-relative-or-authority-state}{\texttt{ {\ttfamily \char`\"{}special relative or authority\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#path-or-authority-state}{\texttt{ {\ttfamily \char`\"{}path or authority\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#relative-state}{\texttt{ {\ttfamily \char`\"{}relative\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#relative-slash-state}{\texttt{ {\ttfamily \char`\"{}relative slash\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#special-authority-slashes-state}{\texttt{ {\ttfamily \char`\"{}special authority slashes\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#special-authority-ignore-slashes-state}{\texttt{ {\ttfamily \char`\"{}special authority ignore slashes\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#authority-state}{\texttt{ {\ttfamily \char`\"{}authority\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#host-state}{\texttt{ {\ttfamily \char`\"{}host\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#hostname-state}{\texttt{ {\ttfamily \char`\"{}hostname\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#port-state}{\texttt{ {\ttfamily \char`\"{}port\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#file-state}{\texttt{ {\ttfamily \char`\"{}file\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#file-slash-state}{\texttt{ {\ttfamily \char`\"{}file slash\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#file-host-state}{\texttt{ {\ttfamily \char`\"{}file host\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#path-start-state}{\texttt{ {\ttfamily \char`\"{}path start\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#path-state}{\texttt{ {\ttfamily \char`\"{}path\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#cannot-be-a-base-url-path-state}{\texttt{ {\ttfamily \char`\"{}cannot-\/be-\/a-\/base-\/\+URL path\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#query-state}{\texttt{ {\ttfamily \char`\"{}query\char`\"{}}}}
\item \href{https://url.spec.whatwg.org/\#fragment-state}{\texttt{ {\ttfamily \char`\"{}fragment\char`\"{}}}}
\end{DoxyItemize}

The URL record type has the following API\+:


\begin{DoxyItemize}
\item \href{https://url.spec.whatwg.org/\#concept-url-scheme}{\texttt{ {\ttfamily scheme}}}
\item \href{https://url.spec.whatwg.org/\#concept-url-username}{\texttt{ {\ttfamily username}}}
\item \href{https://url.spec.whatwg.org/\#concept-url-password}{\texttt{ {\ttfamily password}}}
\item \href{https://url.spec.whatwg.org/\#concept-url-host}{\texttt{ {\ttfamily host}}}
\item \href{https://url.spec.whatwg.org/\#concept-url-port}{\texttt{ {\ttfamily port}}}
\item \href{https://url.spec.whatwg.org/\#concept-url-path}{\texttt{ {\ttfamily path}}} (as an array)
\item \href{https://url.spec.whatwg.org/\#concept-url-query}{\texttt{ {\ttfamily query}}}
\item \href{https://url.spec.whatwg.org/\#concept-url-fragment}{\texttt{ {\ttfamily fragment}}}
\item \href{https://url.spec.whatwg.org/\#url-cannot-be-a-base-url-flag}{\texttt{ {\ttfamily cannot\+Be\+ABase\+URL}}} (as a boolean)
\end{DoxyItemize}

These properties should be treated with care, as in general changing them will cause the URL record to be in an inconsistent state until the appropriate invocation of {\ttfamily basic\+URLParse} is used to fix it up. You can see examples of this in the URL Standard, where there are many step sequences like \char`\"{}4. Set context object’s url’s fragment to the empty string. 5. Basic URL parse \+\_\+input\+\_\+ with context object’s url as \+\_\+url\+\_\+ and fragment state as \+\_\+state override\+\_\+.\char`\"{} In between those two steps, a URL record is in an unusable state.

The return value of \char`\"{}failure\char`\"{} in the spec is represented by {\ttfamily null}. That is, functions like {\ttfamily parse\+URL} and {\ttfamily basic\+URLParse} can return {\itshape either} a URL record {\itshape or} {\ttfamily null}.\hypertarget{md_sfcode_node_modules_whatwg_url_README_autotoc_md34038}{}\doxysubsection{$<$tt$>$whatwg-\/url/webidl2js-\/wrapper$<$/tt$>$ module}\label{md_sfcode_node_modules_whatwg_url_README_autotoc_md34038}
This module exports the {\ttfamily URL} and {\ttfamily URLSearch\+Params} \href{https://github.com/jsdom/webidl2js\#for-interfaces}{\texttt{ interface wrappers API}} generated by \href{https://github.com/jsdom/webidl2js}{\texttt{ webidl2js}}.\hypertarget{md_sfcode_node_modules_whatwg_url_README_autotoc_md34039}{}\doxysection{Development instructions}\label{md_sfcode_node_modules_whatwg_url_README_autotoc_md34039}
First, install \href{https://nodejs.org/}{\texttt{ Node.\+js}}. Then, fetch the dependencies of whatwg-\/url, by running from this directory\+: \begin{DoxyVerb}npm install
\end{DoxyVerb}
 To run tests\+: \begin{DoxyVerb}npm test
\end{DoxyVerb}
 To generate a coverage report\+: \begin{DoxyVerb}npm run coverage
\end{DoxyVerb}
 To build and run the live viewer\+: \begin{DoxyVerb}npm run prepare
npm run build-live-viewer
\end{DoxyVerb}
 Serve the contents of the {\ttfamily live-\/viewer} directory using any web server.\hypertarget{md_sfcode_node_modules_whatwg_url_README_autotoc_md34040}{}\doxysection{Supporting whatwg-\/url}\label{md_sfcode_node_modules_whatwg_url_README_autotoc_md34040}
The jsdom project (including whatwg-\/url) is a community-\/driven project maintained by a team of \href{https://github.com/orgs/jsdom/people}{\texttt{ volunteers}}. You could support us by\+:


\begin{DoxyItemize}
\item \href{https://tidelift.com/subscription/pkg/npm-whatwg-url?utm_source=npm-whatwg-url&utm_medium=referral&utm_campaign=readme}{\texttt{ Getting professional support for whatwg-\/url}} as part of a Tidelift subscription. Tidelift helps making open source sustainable for us while giving teams assurances for maintenance, licensing, and security.
\item Contributing directly to the project. 
\end{DoxyItemize}