Created
September 30, 2021 17:30
-
-
Save lucasmartins1994/c5eb2d35098563c4893d965419afe6b3 to your computer and use it in GitHub Desktop.
Function parse url
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
function url($url) { | |
var url = $url.split( '//' ); | |
if (url[0] === "http:" || url[0] === "https:") { | |
var protocol = url[0] + "//"; | |
var host = url[1].split( '/' )[0]; | |
url = protocol + host; | |
var path = $url.split(url)[1]; | |
return { | |
protocol: protocol, | |
host: host, | |
path: path | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment