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

Function parseBitbucketURL

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

Source from the content-addressed store, hash-verified

107 * @returns Parsed repository information
108 */
109const parseBitbucketURL = (url) => {
110 const pathLength = 4
111 const parts = url.pathname.split('/')
112 const isSubdirectory = parts.length > pathLength
113 const owner = parts[1]
114 const repo = parts[2]
115
116 // Native URL object uses .search (with leading ?) not .query
117 const queryString = url.search ? url.search.slice(1) : ''
118 const query = qs.parse(queryString)
119 // Use the helper function to safely extract the 'at' parameter
120 const branch =
121 'at' in query
122 ? decodeURIComponent(getStringQueryParam(url, 'at'))
123 : 'master'
124
125 // validate if given url is a valid Bitbucket url
126 validateUrl({
127 url,
128 hostname: 'bitbucket.org',
129 service: 'Bitbucket',
130 owner,
131 repo,
132 })
133
134 const downloadUrl = `https://bitbucket.org/${owner}/${repo}/get/${branch}.zip`
135
136 return {
137 owner,
138 repo,
139 branch,
140 downloadUrl,
141 isSubdirectory,
142 pathToDirectory: getPathDirectory(pathLength + 1, parts),
143 username: url.username || '',
144 password: url.password || '',
145 }
146}
147
148/**
149 * Parse Bitbucket server URL

Callers 1

parseRepoURLFunction · 0.85

Calls 3

getStringQueryParamFunction · 0.85
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…