function parseURI(url) {
var m = String(url).replace(/^\s+|\s+$/g, ‘’).match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
// authority = ‘//‘ + user + ‘:’ + pass ‘@‘ + hostname + ‘:’ port
return (m ? {
href: m[0] || ‘’,
protocol: m[1] || ‘’,
authority: m[2] || ‘’,
host: m[3] || ‘’,
hostname: m[4] || ‘’,
port: m[5] || ‘’,
pathname: m[6] || ‘’,
search: m[7] || ‘’,
hash: m[8] || ‘’
} : null);
}
Created
April 18, 2018 07:21
-
-
Save ydhao/9e892f23623dde9ca99ddf488d4ad893 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment