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

Function parseBitbucketServerURL

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

Source from the content-addressed store, hash-verified

151 * @returns
152 */
153const parseBitbucketServerURL = (url) => {
154 const pathLength = 9
155 const parts = url.pathname.split('/')
156 const isSubdirectory = parts.length > pathLength
157 const owner = parts[5]
158 const repo = parts[7]
159
160 // Native URL object uses .search (with leading ?) not .query
161 const queryString = url.search ? url.search.slice(1) : ''
162 const query = qs.parse(queryString)
163 // Use the helper function to safely extract the 'at' parameter
164 const branch =
165 'at' in query
166 ? decodeURIComponent(getStringQueryParam(url, 'at'))
167 : 'master'
168
169 const downloadUrl = `${url.protocol}//${url.hostname}/rest/api/latest/projects/${owner}/repos/${repo}/archive${url.search}&format=zip`
170
171 return {
172 owner,
173 repo,
174 branch,
175 downloadUrl,
176 isSubdirectory,
177 pathToDirectory: getPathDirectory(pathLength + 1, parts),
178 username: url.username || '',
179 password: url.password || '',
180 }
181}
182
183/**
184 * Retrieve Bitbucket server info

Callers 1

parseRepoURLFunction · 0.85

Calls 2

getStringQueryParamFunction · 0.85
getPathDirectoryFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…