From b67656aef00732101ceff70060b486b18be1ea1b Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Fri, 18 Aug 2023 15:41:33 -0400 Subject: [PATCH] Fix bug in create-remix git repo path collisions --- packages/create-remix/copy-template.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/create-remix/copy-template.ts b/packages/create-remix/copy-template.ts index e46abd320a0..ae3c3b2b9b1 100644 --- a/packages/create-remix/copy-template.ts +++ b/packages/create-remix/copy-template.ts @@ -312,7 +312,15 @@ async function downloadAndExtractTarball( header.name = header.name.replace(`${originalDirName}/`, ""); if (filePath) { - if (header.name.startsWith(filePath)) { + // Include trailing slash on startsWith when filePath doesn't include + // it so something like `templates/remix` doesn't inadvertently + // include `templates/remix-javascript/*` files + if ( + (filePath.endsWith(path.posix.sep) && + header.name.startsWith(filePath)) || + (!filePath.endsWith(path.posix.sep) && + header.name.startsWith(filePath + path.posix.sep)) + ) { filePathHasFiles = true; header.name = header.name.replace(filePath, ""); } else {