(url)
| 151 | * @returns |
| 152 | */ |
| 153 | const 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 |
no test coverage detected
searching dependent graphs…