MCPcopy Index your code
hub / github.com/serverless/serverless / parseRepoURL

Function parseRepoURL

packages/sf-core/src/utils/https/index.js:277–324  ·  view source on GitHub ↗
(inputUrl)

Source from the content-addressed store, hash-verified

275 * @returns A Promise
276 */
277export const parseRepoURL = async (inputUrl) => {
278 if (!inputUrl) {
279 return new Error('URL is required')
280 }
281
282 const url = parseUrl(inputUrl.replace(/\/$/, ''))
283 if (url.auth) {
284 const [username, password] = url.auth.split(':')
285 url.username = username
286 url.password = password
287 }
288
289 // check if url parameter is a valid url
290 if (!url.host && !url.href.startsWith('git@')) {
291 return new Error('The URL you passed is not valid')
292 }
293
294 if (isPlainGitURL(url.href)) {
295 return parsePlainGitURL(inputUrl)
296 } else if (
297 url.hostname === 'github.com' ||
298 url.hostname.includes('github.')
299 ) {
300 return parseGitHubURL(url)
301 } else if (url.hostname === 'bitbucket.org') {
302 return parseBitbucketURL(url)
303 } else if (url.hostname === 'gitlab.com') {
304 return parseGitlabURL(url)
305 }
306
307 // Check if it's a private Bitbucket server
308 const msg =
309 'The URL you passed is not one of the valid providers: "GitHub", "GitHub Entreprise", "Bitbucket", "Bitbucket Server" or "GitLab".'
310 const err = new Error(msg)
311 const isBitbucket = await retrieveBitbucketServerInfo(url)
312 if (!isBitbucket) {
313 throw err
314 }
315
316 // build download URL
317 let parsedBitbucketServerURL
318 try {
319 parsedBitbucketServerURL = parseBitbucketServerURL(url)
320 } catch (error) {
321 throw err
322 }
323 return parsedBitbucketServerURL
324}
325
326/**
327 * Download template from repository

Callers 2

downloadTemplateFunction · 0.85
download.test.jsFile · 0.85

Calls 8

parseUrlFunction · 0.85
isPlainGitURLFunction · 0.85
parsePlainGitURLFunction · 0.85
parseGitHubURLFunction · 0.85
parseBitbucketURLFunction · 0.85
parseGitlabURLFunction · 0.85
parseBitbucketServerURLFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…