We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f46f4bd commit 8d603aeCopy full SHA for 8d603ae
packages/open-next/src/utils/regex.ts
@@ -1,3 +1,8 @@
1
+type Options = {
2
+ escape?: boolean;
3
+ flags?: string;
4
+};
5
+
6
/**
7
* Constructs a regular expression for a path that supports separators for multiple platforms
8
* - Uses posix separators (`/`) as the input that should be made cross-platform.
@@ -12,11 +17,11 @@
12
17
*/
13
18
export function getCrossPlatformPathRegex(
14
19
regex: string,
15
- opts: { escape: boolean } = { escape: true },
20
+ { escape: shouldEscape = true, flags = "g" }: Options = {},
16
21
) {
22
const newExpr = (
- opts.escape ? regex.replace(/([[\]().*+?^$|{}\\])/g, "\\$1") : regex
23
+ shouldEscape ? regex.replace(/([[\]().*+?^$|{}\\])/g, "\\$1") : regex
24
).replaceAll("/", String.raw`(?:\/|\\)`);
25
- return new RegExp(newExpr, "g");
26
+ return new RegExp(newExpr, flags);
27
}
0 commit comments