From 409adf6c0e3170c38c708d8dfdc9100745e5ad48 Mon Sep 17 00:00:00 2001 From: nicgirault Date: Tue, 17 Mar 2020 11:08:29 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20fix=20handling=20of=20/in?= =?UTF-8?q?dex.html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cloudfront.spec.ts | 1 + src/cloudfront.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cloudfront.spec.ts b/src/cloudfront.spec.ts index 41b4df7..b45bca0 100644 --- a/src/cloudfront.spec.ts +++ b/src/cloudfront.spec.ts @@ -303,6 +303,7 @@ describe("cloudfront", () => { describe("getCacheInvalidations", () => { it.each([ { input: "index.html", expectedOutput: "/index.html" }, + { input: "/index.html", expectedOutput: "/index.html" }, { input: "index.html, hello.html", subFolder: undefined, diff --git a/src/cloudfront.ts b/src/cloudfront.ts index 5db7cc4..92f0e91 100644 --- a/src/cloudfront.ts +++ b/src/cloudfront.ts @@ -352,7 +352,7 @@ export const getCacheInvalidations = ( ) => cacheInvalidations .split(",") - .map(string => string.trim().replace(/$\//, "")) + .map(string => string.trim().replace(/^\//, "")) .map(string => (subFolder ? `/${subFolder}/${string}` : `/${string}`)) .join(",");