-
-
Save legale/82930a6a783f61fe5f6091d37fc738b6 to your computer and use it in GitHub Desktop.
php parse_url() JS analog
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
function parse_url(uri){ | |
var a = document.createElement('a'); | |
a.href = uri; | |
return {scheme: a.protocol, user: a.username, pass: a.password, | |
host: a.hostname, port: a.port, path: a.pathname, | |
query: a.search, fragment: a.hash | |
} | |
} | |
//demo | |
parse_url("http://user:password@example.com:3000/pathname/?search=test#hash"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
js analog of the php function parse_url