\href{https://ci.testling.com/lydell/resolve-url}{\texttt{ }}

Like Node.\+js’ \href{http://nodejs.org/api/path.html\#path_path_resolve_from_to}{\texttt{ {\ttfamily path.\+resolve}}}/\href{http://nodejs.org/api/url.html\#url_url_resolve_from_to}{\texttt{ {\ttfamily url.\+resolve}}} for the browser.


\begin{DoxyCode}{0}
\DoxyCodeLine{var resolveUrl = require("{}resolve-\/url"{})}
\DoxyCodeLine{}
\DoxyCodeLine{window.location}
\DoxyCodeLine{// https://example.com/articles/resolving-\/urls/edit}
\DoxyCodeLine{}
\DoxyCodeLine{resolveUrl("{}remove"{})}
\DoxyCodeLine{// https://example.com/articles/resolving-\/urls/remove}
\DoxyCodeLine{}
\DoxyCodeLine{resolveUrl("{}/static/scripts/app.js"{})}
\DoxyCodeLine{// https://example.com/static/scripts/app.js}
\DoxyCodeLine{}
\DoxyCodeLine{// Imagine /static/scripts/app.js contains `//\# sourceMappingURL=../source-\/maps/app.js.map`}
\DoxyCodeLine{resolveUrl("{}/static/scripts/app.js"{}, "{}../source-\/maps/app.js.map"{})}
\DoxyCodeLine{// https://example.com/static/source-\/maps/app.js.map}
\DoxyCodeLine{}
\DoxyCodeLine{resolveUrl("{}/static/scripts/app.js"{}, "{}../source-\/maps/app.js.map"{}, "{}../coffee/app.coffee"{})}
\DoxyCodeLine{// https://example.com/static/coffee/app.coffee}
\DoxyCodeLine{}
\DoxyCodeLine{resolveUrl("{}//cdn.example.com/jquery.js"{})}
\DoxyCodeLine{// https://cdn.example.com/jquery.js}
\DoxyCodeLine{}
\DoxyCodeLine{resolveUrl("{}http://foo.org/"{})}
\DoxyCodeLine{// http://foo.org/ }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_resolve_url_readme_autotoc_md24399}{}\doxysection{Installation}\label{md_sfcode_node_modules_resolve_url_readme_autotoc_md24399}

\begin{DoxyItemize}
\item {\ttfamily npm install resolve-\/url}
\item {\ttfamily bower install resolve-\/url}
\item {\ttfamily component install lydell/resolve-\/url}
\end{DoxyItemize}

Works with Common\+JS, AMD and browser globals, through UMD.\hypertarget{md_sfcode_node_modules_resolve_url_readme_autotoc_md24400}{}\doxysection{Usage}\label{md_sfcode_node_modules_resolve_url_readme_autotoc_md24400}
\hypertarget{md_sfcode_node_modules_resolve_url_readme_autotoc_md24401}{}\doxysubsubsection{$<$tt$>$resolve\+Url(...\+urls)$<$/tt$>$}\label{md_sfcode_node_modules_resolve_url_readme_autotoc_md24401}
Pass one or more urls. Resolves the last one to an absolute url, using the previous ones and {\ttfamily window.\+location}.

It’s like starting out on {\ttfamily window.\+location}, and then clicking links with the urls as {\ttfamily href} attributes in order, from left to right.

Unlike Node.\+js’ \href{http://nodejs.org/api/path.html\#path_path_resolve_from_to}{\texttt{ {\ttfamily path.\+resolve}}}, this function always goes through all of the arguments, from left to right. {\ttfamily path.\+resolve} goes from right to left and only in the worst case goes through them all. Should that matter.

Actually, the function is {\itshape really} like clicking a lot of links in series\+: An actual {\ttfamily $<$a$>$} gets its {\ttfamily href} attribute set for each url! This means that the url resolution of the browser is used, which makes this module really light-\/weight.

Also note that this functions deals with urls, not paths, so in that respect it has more in common with Node.\+js’ \href{http://nodejs.org/api/url.html\#url_url_resolve_from_to}{\texttt{ {\ttfamily url.\+resolve}}}. But the arguments are more like \href{http://nodejs.org/api/path.html\#path_path_resolve_from_to}{\texttt{ {\ttfamily path.\+resolve}}}.\hypertarget{md_sfcode_node_modules_resolve_url_readme_autotoc_md24402}{}\doxysection{Tests}\label{md_sfcode_node_modules_resolve_url_readme_autotoc_md24402}
Run {\ttfamily npm test}, which lints the code and then gives you a link to open in a browser of choice (using {\ttfamily testling}).\hypertarget{md_sfcode_node_modules_resolve_url_readme_autotoc_md24403}{}\doxysection{License}\label{md_sfcode_node_modules_resolve_url_readme_autotoc_md24403}
\mbox{[}The X11 (“\+MIT”) License\mbox{]}(LICENSE). 