Skip to content

Commit 510ca16

Browse files
fix: support branch names with @ in tarball resolver
1 parent 7831971 commit 510ca16

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

packages/app/fixtures/workflow_run.in_progress.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"id": 9394452824,
77
"name": "Preview & Release",
88
"node_id": "WFR_kwLOLiqblM8AAAACL_P5WA",
9-
"head_branch": "main",
9+
"head_branch": "@test/@chaotic.branch/name-@v1.@",
1010
"head_sha": "ded05e838c418096e5dd77a29101c8af9e73daea",
1111
"path": ".github/workflows/ci.yml",
1212
"display_title": "chore: 007 (#94)",

packages/app/server/middleware/tarball-resolver.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ const ALLOWED_METHODS = new Set(["GET", "HEAD"]);
88
export default eventHandler(async (event) => {
99
let decodedPath: string;
1010
try {
11-
const path = event.path.split("?")[0];
11+
const path = event.path
12+
.split("?")[0]
13+
// yarn support
14+
.replace(/\.tgz$/, "");
1215
decodedPath = decodeURIComponent(path);
1316
} catch {
1417
throw createError({
@@ -17,14 +20,21 @@ export default eventHandler(async (event) => {
1720
});
1821
}
1922

20-
const lastAtIndex = decodedPath.lastIndexOf("@");
21-
if (lastAtIndex === -1) return;
23+
let separatorIndex = -1;
2224

23-
let refOrSha = decodedPath.slice(lastAtIndex + 1).replace(/\.tgz$/, "");
24-
if (!refOrSha) return;
25+
for (let i = 2; i < decodedPath.length - 1; i++) {
26+
if (decodedPath[i] === "@" && decodedPath[i - 1] !== "/") {
27+
separatorIndex = i;
28+
break;
29+
}
30+
}
31+
32+
if (separatorIndex === -1) return;
33+
34+
let refOrSha = decodedPath.slice(separatorIndex + 1);
2535

2636
const pathSegments = decodedPath
27-
.slice(0, lastAtIndex)
37+
.slice(0, separatorIndex)
2838
.split("/")
2939
.filter(Boolean);
3040
if (pathSegments.length === 0) return;

0 commit comments

Comments
 (0)