Skip to content

Commit

Permalink
make regex more strict
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Dec 27, 2024
1 parent 82ab4f4 commit c9bf5aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, ".*")}$`,
);
}
4 changes: 2 additions & 2 deletions test/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ describe("inferPkgExternals", () => {
"test",
"optional",
"test/extra/utils",
/test\/drivers\/.*\.js$/,
/#.*$/,
/^test\/drivers\/.*\.js$/,
/^#.*$/,
"#test",
]);
});
Expand Down

0 comments on commit c9bf5aa

Please sign in to comment.