Skip to content

Instantly share code, notes, and snippets.

@ZhihaoLau
Created April 10, 2018 17:29
Show Gist options
  • Save ZhihaoLau/c152a0a35ef6f11f32f9e5716d494352 to your computer and use it in GitHub Desktop.
Save ZhihaoLau/c152a0a35ef6f11f32f9e5716d494352 to your computer and use it in GitHub Desktop.
parseUrl
export function parseUrl(url) {
let a = document.createElement('a')
a.href = url
return {
href: a.href,
protocol: a.protocol,
host: a.host,
hostname: a.hostname,
port: a.port,
pathname: a.pathname,
search: a.search,
hash: a.hash,
origin: a.origin
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment