Created
April 12, 2018 12:28
-
-
Save bmorwood/9e9535540b1f16090632b45e2f72de79 to your computer and use it in GitHub Desktop.
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
export function getUrlProps(url) { | |
var match = url.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/); | |
return match && { | |
url: url, | |
protocol: match[1], | |
host: match[2], | |
hostname: match[3], | |
port: match[4], | |
pathname: match[5], | |
search: match[6], | |
hash: match[7] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment