\href{http://unshift.io}{\texttt{ }}\href{http://browsenpm.org/package/original}{\texttt{ }}\href{https://travis-ci.org/unshiftio/original}{\texttt{ }}\href{https://david-dm.org/unshiftio/original}{\texttt{ }}\href{https://coveralls.io/r/unshiftio/original?branch=master}{\texttt{ }}\href{http://webchat.freenode.net/?channels=unshift}{\texttt{ }}

Original generates the origin URL for a given URL or URL object. In addition to that it also comes with a simple {\ttfamily same} function to check if two URL\textquotesingle{}s have the same origin.\hypertarget{md_sfcode_node_modules_original_README_autotoc_md19247}{}\doxysection{Install}\label{md_sfcode_node_modules_original_README_autotoc_md19247}
This module is browserify and node compatible and is therefor release in the npm registry and can be installed using\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{npm install -\/-\/save original }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_original_README_autotoc_md19248}{}\doxysection{Usage}\label{md_sfcode_node_modules_original_README_autotoc_md19248}
In all the examples we assume that the module is loaded using\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{'use strict';}
\DoxyCodeLine{}
\DoxyCodeLine{var origin = require('original'); }

\end{DoxyCode}


To get the origin of a given URL simply call {\ttfamily origin} function with any given URL to get origin.


\begin{DoxyCode}{0}
\DoxyCodeLine{var o = origin('https://google.com/foo/bar?path');}
\DoxyCodeLine{}
\DoxyCodeLine{// o = https://google.com }

\end{DoxyCode}


To compare if two URL\textquotesingle{}s share the same origin you can call the {\ttfamily same} method.


\begin{DoxyCode}{0}
\DoxyCodeLine{if (origin.same('https://google.com/foo', 'https://primus.io')) \{}
\DoxyCodeLine{  console.log('same');}
\DoxyCodeLine{\} else \{}
\DoxyCodeLine{  console.log('guess what, google.com and primus.io are not the same origin');}
\DoxyCodeLine{\} }

\end{DoxyCode}


And that\textquotesingle{}s it.\hypertarget{md_sfcode_node_modules_original_README_autotoc_md19249}{}\doxysection{License}\label{md_sfcode_node_modules_original_README_autotoc_md19249}
MIT 