From c9bf5aae0146f4eef152f34907cd145d48d1f18f Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 28 Dec 2024 00:28:59 +0100 Subject: [PATCH] make regex more strict --- src/utils.ts | 2 +- test/utils.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index b2f1702..6279a8d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -198,6 +198,6 @@ function pathToRegex(path: string): string | RegExp { return path; } return new RegExp( - path.replace(/\./g, String.raw`\.`).replace(/\*/g, ".*") + "$", + `^${path.replace(/\./g, String.raw`\.`).replace(/\*/g, ".*")}$`, ); } diff --git a/test/utils.test.ts b/test/utils.test.ts index 2f38684..c7987c8 100644 --- a/test/utils.test.ts +++ b/test/utils.test.ts @@ -82,8 +82,8 @@ describe("inferPkgExternals", () => { "test", "optional", "test/extra/utils", - /test\/drivers\/.*\.js$/, - /#.*$/, + /^test\/drivers\/.*\.js$/, + /^#.*$/, "#test", ]); });