From 4573031972107e0af692492ee967d9022deafd7b Mon Sep 17 00:00:00 2001
From: Ashcon Partovi <ashcon@partovi.net>
Date: Wed, 1 Mar 2023 17:36:06 -0800
Subject: [PATCH] Do not cache action releases

---
 dist/setup.js | 10 +++++-----
 src/setup.ts  | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/dist/setup.js b/dist/setup.js
index f7256c4..1c543ee 100644
--- a/dist/setup.js
+++ b/dist/setup.js
@@ -60,14 +60,14 @@ function getDownloadUrl(options) {
         };
     }
     const release = encodeURIComponent(options?.version ?? "latest");
-    const os = options?.os ?? process.platform;
-    const arch = options?.arch ?? process.arch;
-    const avx2 = options?.avx2 ?? true;
-    const profile = options?.profile ?? false;
+    const os = encodeURIComponent(options?.os ?? process.platform);
+    const arch = encodeURIComponent(options?.arch ?? process.arch);
+    const avx2 = encodeURIComponent(options?.avx2 ?? true);
+    const profile = encodeURIComponent(options?.profile ?? false);
     const { href } = new URL(`${release}/${os}/${arch}?avx2=${avx2}&profile=${profile}`, "https://bun.sh/download/");
     return {
         url: href,
-        cacheKey: /^canary|latest$/i.test(release)
+        cacheKey: /^latest|canary|action/i.test(release)
             ? null
             : `bun-${release}-${os}-${arch}-${avx2}-${profile}`,
     };
diff --git a/src/setup.ts b/src/setup.ts
index d475963..2880c77 100644
--- a/src/setup.ts
+++ b/src/setup.ts
@@ -80,17 +80,17 @@ function getDownloadUrl(options?: {
     };
   }
   const release = encodeURIComponent(options?.version ?? "latest");
-  const os = options?.os ?? process.platform;
-  const arch = options?.arch ?? process.arch;
-  const avx2 = options?.avx2 ?? true;
-  const profile = options?.profile ?? false;
+  const os = encodeURIComponent(options?.os ?? process.platform);
+  const arch = encodeURIComponent(options?.arch ?? process.arch);
+  const avx2 = encodeURIComponent(options?.avx2 ?? true);
+  const profile = encodeURIComponent(options?.profile ?? false);
   const { href } = new URL(
     `${release}/${os}/${arch}?avx2=${avx2}&profile=${profile}`,
     "https://bun.sh/download/"
   );
   return {
     url: href,
-    cacheKey: /^canary|latest$/i.test(release)
+    cacheKey: /^latest|canary|action/i.test(release)
       ? null
       : `bun-${release}-${os}-${arch}-${avx2}-${profile}`,
   };