Skip to content

Instantly share code, notes, and snippets.

@qwersk
Created July 18, 2019 05:16
Show Gist options
  • Save qwersk/54fd1ed2271bb84875cacb44e22b512d to your computer and use it in GitHub Desktop.
Save qwersk/54fd1ed2271bb84875cacb44e22b512d to your computer and use it in GitHub Desktop.
Parse url #JS
var url = "https://developer.mozilla.org/en-US/Web/JavaScript";
var parsedURL = /^(\w+)\:\/\/([^\/]+)\/(.*)$/.exec(url);
var [, protocol, fullhost, fullpath] = parsedURL;
console.log(protocol); // выведет "https"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment