Created
April 10, 2018 17:29
-
-
Save ZhihaoLau/c152a0a35ef6f11f32f9e5716d494352 to your computer and use it in GitHub Desktop.
parseUrl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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