aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Justin "J.R." Hill <justin@so.dang.cool> 2023-09-27 18:22:50 -0800
committerGravatar GitHub <noreply@github.com> 2023-09-27 19:22:50 -0700
commit1d6d639352d58e65f6bbeff0188c01efbfa59bf8 (patch)
treee7ead427bc25b58f0fcd3d8592c1bb14f86d4cfe /src
parent7cd1dc2817158f9a27605ec5bac33575b9ef12f3 (diff)
downloadbun-1d6d639352d58e65f6bbeff0188c01efbfa59bf8.tar.gz
bun-1d6d639352d58e65f6bbeff0188c01efbfa59bf8.tar.zst
bun-1d6d639352d58e65f6bbeff0188c01efbfa59bf8.zip
fix(bun install): Handle vercel and github tarball path dependencies (#6122)
* fix(bun install): Handle vercel and github tarball path dependencies * test(bun install): test tarball path with when * Simplify github tarball detection --------- Co-authored-by: bun <noreply@oven.sh>
Diffstat (limited to 'src')
-rw-r--r--src/install/dependency.zig25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/install/dependency.zig b/src/install/dependency.zig
index 9c7bcf479..01c1ecd86 100644
--- a/src/install/dependency.zig
+++ b/src/install/dependency.zig
@@ -221,6 +221,26 @@ pub inline fn isGitHubRepoPath(dependency: string) bool {
return hash_index != dependency.len - 1 and first_slash_index > 0 and first_slash_index != dependency.len - 1;
}
+// Github allows for the following format of URL:
+// https://github.com/<org>/<repo>/tarball/<ref>
+// This is a legacy (but still supported) method of retrieving a tarball of an
+// entire source tree at some git reference. (ref = branch, tag, etc. Note: branch
+// can have arbitrary number of slashes)
+pub inline fn isGitHubTarballPath(dependency: string) bool {
+ var parts = strings.split(dependency, "/");
+
+ var n_parts: usize = 0;
+
+ while (parts.next()) |part| {
+ n_parts += 1;
+ if (n_parts == 3) {
+ return strings.eql(part, "tarball");
+ }
+ }
+
+ return false;
+}
+
// This won't work for query string params, but I'll let someone file an issue
// before I add that.
pub inline fn isTarball(dependency: string) bool {
@@ -494,8 +514,11 @@ pub const Version = struct {
else => {},
}
if (strings.hasPrefixComptime(url, "github.com/")) {
- if (isGitHubRepoPath(url["github.com/".len..])) return .github;
+ const path = url["github.com/".len..];
+ if (isGitHubTarballPath(path)) return .tarball;
+ if (isGitHubRepoPath(path)) return .github;
}
+ return .tarball;
}
}
},