Skip to content

Instantly share code, notes, and snippets.

@defrex
Created February 22, 2014 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defrex/9162186 to your computer and use it in GitHub Desktop.
Save defrex/9162186 to your computer and use it in GitHub Desktop.
function parseUrl(url) {
var urlParser = document.createElement('a');
urlParser.href = url;
return {
hostname: urlParser.hostname,
pathname: urlParser.pathname,
search: urlParser.search,
hash: urlParser.hash,
port: urlParser.port,
protocol: urlParser.protocol,
origin: urlParser.origin,
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment