Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

css ninja

function parseProtocol(url) {
  const parsedURL = /^(w+)://([^/]+)/(.*)$/.exec(url);
  if (!parsedURL) {
    return false;
  }
  console.log(parsedURL);
  // ["https://developer.mozilla.org/en-US/docs/Web/JavaScript",
      "https", "developer.mozilla.org", "en-US/docs/Web/JavaScript"]

  const [, protocol, fullhost, fullpath] = parsedURL;
  return protocol;
}

console.log(parseProtocol('https://developer.mozilla.org/en-US/docs/Web/JavaScript'));
// "https"
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #css #ninja
ADD COMMENT
Topic
Name
7+5 =