mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Ensure escapeRegExp returns an empty string when passing falsy values (#4432)
* Enable escapeRegExp tests * Ensure escapeRegExp returns an empty string when passing falsy values * Add parens around expression in escapeRegExp
This commit is contained in:
committed by
John-David Dalton
parent
9971765d0c
commit
91c9cb1ea3
@@ -22,7 +22,7 @@ const reHasRegExpChar = RegExp(reRegExpChar.source)
|
||||
function escapeRegExp(string) {
|
||||
return (string && reHasRegExpChar.test(string))
|
||||
? string.replace(reRegExpChar, '\\$&')
|
||||
: string
|
||||
: (string || '')
|
||||
}
|
||||
|
||||
export default escapeRegExp
|
||||
|
||||
Reference in New Issue
Block a user