diff --git a/lib/modules/manager/bazel/rules/http.ts b/lib/modules/manager/bazel/rules/http.ts index 7f773b97fabb350dc8fe4d6f0170081e788f76f4..9f1ba2b35008cae0bf5be3b0d067d008f2b8798f 100644 --- a/lib/modules/manager/bazel/rules/http.ts +++ b/lib/modules/manager/bazel/rules/http.ts @@ -17,23 +17,22 @@ export function parseArchiveUrl( if (!url || url.host !== 'github.com' || !url.pathname) { return null; } - const path = url.pathname.split('/').slice(1); - const repo = path[0] + '/' + path[1]; + const [p0, p1, p2, p3, p4, p5] = url.pathname.split('/').slice(1); + const repo = p0 + '/' + p1; let datasource = ''; let currentValue: string | null = null; - if (path[2] === 'releases' && path[3] === 'download') { + if (p2 === 'releases' && p3 === 'download') { + // https://github.com/foo/bar/releases/download/1.2.3/bar-1.2.3.tar.gz datasource = GithubReleasesDatasource.id; - currentValue = path[4]; - } else if ( - path[2] === 'archive' && - path[3] === 'refs' && - path[4] === 'tags' - ) { + currentValue = p4; + } else if (p2 === 'archive' && p3 === 'refs' && p4 === 'tags') { + // https://github.com/foo/bar/archive/refs/tags/v1.2.3.tar.gz datasource = GithubTagsDatasource.id; - currentValue = path[5]; - } else if (path[2] === 'archive') { + currentValue = p5; + } else if (p2 === 'archive') { + // https://github.com/foo/bar/archive/1.2.3.tar.gz datasource = GithubTagsDatasource.id; - currentValue = path[3]; + currentValue = p3; } if (currentValue) {