Created
June 30, 2017 07:51
-
-
Save no1xsyzy/7cbbba5f78c96e274d09999c4e7cfcaa to your computer and use it in GitHub Desktop.
Function for parsing URLs
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
window.parseURL=function(URL){ | |
let [,schema="",host="",path="",search="",hash=""]= | |
URL.match(/^(?:(?:([^:]+:)?\/\/)?([^\/#?]+))?(?:(\/[^#?]*)?(\?[^#]*)?(#.*)?)?$/); | |
return {schema,host,path,search,hash} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment