Created
August 19, 2014 16:40
-
-
Save kiquetal/eb0e3fc4c0823f025eca to your computer and use it in GitHub Desktop.
parturl
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
http://www.coderholic.com/javascript-the-good-parts/ | |
var parse_url = /^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/; | |
var url = 'http://www.ora.com:80/goodparts?q#fragment'; | |
var result = parse_url.exec(url); | |
var names = ['url', 'scheme', 'slash', 'host', 'port', 'path', 'query', 'hash']; | |
var blanks = ' '; | |
var i; | |
for (i = 0; i < names.length; i += 1) { | |
document.writeln(names[i] + ':' + blanks.substring(names[i].length), result[i]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment