Skip to content

Instantly share code, notes, and snippets.

@there4
Created September 12, 2012 13:12
Show Gist options
  • Save there4/3706510 to your computer and use it in GitHub Desktop.
Save there4/3706510 to your computer and use it in GitHub Desktop.
AMD Javascript Parse URL
// # 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