Created
July 18, 2019 05:16
-
-
Save qwersk/54fd1ed2271bb84875cacb44e22b512d to your computer and use it in GitHub Desktop.
Parse url #JS
This file contains hidden or 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
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