Fixed regex crash when looking for "foo - bar"

This commit is contained in:
Simon Cambier
2023-02-26 16:46:22 +01:00
parent 326506fe72
commit 848bbb5b80

View File

@@ -68,8 +68,9 @@ export function wait(ms: number): Promise<void> {
}
// https://stackoverflow.com/a/3561711
// but we enclose special chars in brackets to avoid them being interpreted as regex
export function escapeRegex(str: string): string {
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, '[$&]')
}
/**