Created
September 12, 2012 13:12
-
-
Save there4/3706510 to your computer and use it in GitHub Desktop.
AMD Javascript Parse URL
This file contains hidden or 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
// # Simple Url Parsing via DOM. | |
// ----------------------------------------------------------------------------- | |
// | |
// * Author: Craig Davis <[email protected]> | |
// | |
define([], function(undefined) { | |
var a = document.createElement('a'); | |
return function (url) { | |
a.href = url; | |
return { | |
host : a.host, | |
hostname : a.hostname, | |
pathname : a.pathname, | |
port : a.port, | |
protocol : a.protocol + '//', | |
search : a.search, | |
hash : a.hash | |
}; | |
} | |
}); | |
/* End of file parse_url.js */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment