refactor(utils): improve escapeStringRegexp (#6013)

This commit is contained in:
三咲智子
2022-02-13 22:48:42 +08:00
committed by GitHub
parent cd8a053b3c
commit 7abc200742
2 changed files with 7 additions and 4 deletions

View File

@ -5,5 +5,8 @@ export {
hyphenate as kebabCase, // alias
} from '@vue/shared'
export const escapeRegexpString = (value = '') =>
String(value).replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
/**
* fork from {@link https://github.com/sindresorhus/escape-string-regexp}
*/
export const escapeStringRegexp = (string = '') =>
string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d')