lib/utils/downloadTemplateFromRepo.js
function parseRepoURL(inputUrl) {
  if (!inputUrl) {
    throw new ServerlessError('URL is required');
  }

  const url = URL.parse(inputUrl.replace(/\/$/, ''));

  // check if url parameter is a valid url
  if (!url.host) {
    throw new ServerlessError('The URL you passed is not a valid URL');
  }

  switch (url.hostname) {
    case 'github.com': {
      return parseGitHubURL(url);
    }
    case 'bitbucket.org': {
      return parseBitbucketURL(url);
    }
    case 'gitlab.com': {
      return parseGitlabURL(url);
    }
    default: {
      const msg =
        'The URL you passed is not one of the valid providers: "GitHub", "Bitbucket", or "GitLab".';
      throw new ServerlessError(msg);
    }
  }
}
function parseRepoURL(inputUrl) {
  if (!inputUrl) {
    throw new ServerlessError('URL is required');
  }

  const url = URL.parse(inputUrl.replace(/\/$/, ''));

  // check if url parameter is a valid url
  if (!url.host) {
    throw new ServerlessError('The URL you passed is not a valid URL');
  }

  switch (url.hostname) {
    case 'github.com': {
      return parseGitHubURL(url);
    }
    case 'bitbucket.org': {
      return parseBitbucketURL(url);
    }
    case 'gitlab.com': {
      return parseGitlabURL(url);
    }
    default: {
      const msg =
        'The URL you passed is not one of the valid providers: "GitHub", "Bitbucket", or "GitLab".';
      throw new ServerlessError(msg);
    }
  }
}
function parseRepoURL ( inputUrl ) { if ( ! inputUrl ) { throw new ServerlessError ( 'URL is required' ) ; } const url = URL . parse ( inputUrl . replace ( / \/$ / , '' ) ) ; // check if url parameter is a valid url if ( ! url . host ) { throw new ServerlessError ( 'The URL you passed is not a valid URL' ) ; } switch ( url . hostname ) { case 'github.com' : { return parseGitHubURL ( url ) ; } case 'bitbucket.org' : { return parseBitbucketURL ( url ) ; } case 'gitlab.com' : { return parseGitlabURL ( url ) ; } default : { const msg = 'The URL you passed is not one of the valid providers: "GitHub", "Bitbucket", or "GitLab".' ; throw new ServerlessError ( msg ) ; } } }
Parse URL and call the appropriate adaptor

@param {string} inputUrl
@throws {ServerlessError}
@returns {Object}
Parse URL and call the appropriate adaptor