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

Function parseGitlabURL

packages/sf-core/src/utils/https/index.js:200–230  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

198 * @returns
199 */
200const parseGitlabURL = (url) => {
201 const pathLength = 4
202 const parts = url.pathname.split('/')
203 const isSubdirectory = parts.length > pathLength
204 const owner = parts[1]
205 const repo = parts[2]
206
207 const branch = isSubdirectory ? parts[pathLength] : 'master'
208
209 // validate if given url is a valid GitLab url
210 validateUrl({
211 url,
212 hostname: 'gitlab.com',
213 service: 'Bitbucket',
214 owner,
215 repo,
216 })
217
218 const downloadUrl = `https://gitlab.com/${owner}/${repo}/-/archive/${branch}/${repo}-${branch}.zip`
219
220 return {
221 owner,
222 repo,
223 branch,
224 downloadUrl,
225 isSubdirectory,
226 pathToDirectory: getPathDirectory(pathLength + 1, parts),
227 username: url.username || '',
228 password: url.password || '',
229 }
230}
231
232/**
233 * Parse plain Git URL

Callers 1

parseRepoURLFunction · 0.85

Calls 2

validateUrlFunction · 0.85
getPathDirectoryFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…