css ninja

Solutions on MaxInterview for css ninja by the best coders in the world

showing results for - "css ninja"
Tristan
07 Nov 2016
1function parseProtocol(url) {
2  const parsedURL = /^(\w+)\:\/\/([^\/]+)\/(.*)$/.exec(url);
3  if (!parsedURL) {
4    return false;
5  }
6  console.log(parsedURL);
7  // ["https://developer.mozilla.org/en-US/docs/Web/JavaScript",      "https", "developer.mozilla.org", "en-US/docs/Web/JavaScript"]
8
9  const [, protocol, fullhost, fullpath] = parsedURL;
10  return protocol;
11}
12
13console.log(parseProtocol('https://developer.mozilla.org/en-US/docs/Web/JavaScript'));
14// "https"
15