(url)
| 107 | * @returns Parsed repository information |
| 108 | */ |
| 109 | const 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 |
no test coverage detected
searching dependent graphs…