Skip to content

Commit c4e1762

Browse files
committed
remove regExpEscape const
1 parent 29024cd commit c4e1762

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/utils.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ export function conditions(options: t.Options): Set<t.Condition> {
1919
return out;
2020
}
2121

22-
/**
23-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/escape
24-
*/
25-
const regExpEscape = (raw: string) => raw.replace(/\./g, '\\$&');
26-
2722
export function walk(name: string, mapping: Mapping, input: string, options?: t.Options): string[] {
2823
let entry = toEntry(name, input);
2924
let c = conditions(options || {});
@@ -49,7 +44,7 @@ export function walk(name: string, mapping: Mapping, input: string, options?: t.
4944

5045
if (!!~tmp) {
5146
match = RegExp(
52-
'^' + regExpEscape(key.substring(0, tmp)) + '(.*)' + regExpEscape(key.substring(1+tmp)) + '$'
47+
'^' + key.substring(0, tmp).replace(/\./g, '\\$&') + '(.*)' + key.substring(1+tmp).replace(/\./g, '\\$&') + '$'
5348
).exec(entry);
5449

5550
if (match && match[1]) {

0 commit comments

Comments
 (0)