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