Skip to content

Instantly share code, notes, and snippets.

@lucasmartins1994
Created September 30, 2021 17:30
Show Gist options
  • Save lucasmartins1994/c5eb2d35098563c4893d965419afe6b3 to your computer and use it in GitHub Desktop.
Save lucasmartins1994/c5eb2d35098563c4893d965419afe6b3 to your computer and use it in GitHub Desktop.
Function parse url
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