Skip to content

Commit 8d603ae

Browse files
committed
change options
1 parent f46f4bd commit 8d603ae

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/open-next/src/utils/regex.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
type Options = {
2+
escape?: boolean;
3+
flags?: string;
4+
};
5+
16
/**
27
* Constructs a regular expression for a path that supports separators for multiple platforms
38
* - Uses posix separators (`/`) as the input that should be made cross-platform.
@@ -12,11 +17,11 @@
1217
*/
1318
export function getCrossPlatformPathRegex(
1419
regex: string,
15-
opts: { escape: boolean } = { escape: true },
20+
{ escape: shouldEscape = true, flags = "g" }: Options = {},
1621
) {
1722
const newExpr = (
18-
opts.escape ? regex.replace(/([[\]().*+?^$|{}\\])/g, "\\$1") : regex
23+
shouldEscape ? regex.replace(/([[\]().*+?^$|{}\\])/g, "\\$1") : regex
1924
).replaceAll("/", String.raw`(?:\/|\\)`);
2025

21-
return new RegExp(newExpr, "g");
26+
return new RegExp(newExpr, flags);
2227
}

0 commit comments

Comments
 (0)