| 3 | import https from "https"; |
| 4 | |
| 5 | function parseGitlabZipPath(urlPath: string): { project: string; branch: string } | null { |
| 6 | const segments = urlPath.split("/").filter(Boolean); |
| 7 | // /api/gitlab-zip/:encodedProject/:branch |
| 8 | if (segments.length < 4 || segments[0] !== "api" || segments[1] !== "gitlab-zip") { |
| 9 | return null; |
| 10 | } |
| 11 | const encodedProject = segments[2]; |
| 12 | const branch = segments[3]; |
| 13 | if (!encodedProject || !branch) return null; |
| 14 | |
| 15 | let project = encodedProject; |
| 16 | try { |
| 17 | project = decodeURIComponent(encodedProject); |
| 18 | } catch { |
| 19 | project = encodedProject; |
| 20 | } |
| 21 | return { project, branch }; |
| 22 | } |
| 23 | |
| 24 | function fetchGitlabArchive(project: string, branch: string, token?: string): Promise<{ |
| 25 | statusCode: number; |