mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +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) {
|
function escapeRegExp(string) {
|
||||||
return (string && reHasRegExpChar.test(string))
|
return (string && reHasRegExpChar.test(string))
|
||||||
? string.replace(reRegExpChar, '\\$&')
|
? string.replace(reRegExpChar, '\\$&')
|
||||||
: string
|
: (string || '')
|
||||||
}
|
}
|
||||||
|
|
||||||
export default escapeRegExp
|
export default escapeRegExp
|
||||||
|
|||||||
Reference in New Issue
Block a user