From 91c9cb1ea3d0973201d8e5f517a93c9f54e3f9e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Am=C3=A9rico?= Date: Thu, 22 Aug 2019 20:08:13 -0300 Subject: [PATCH] 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 --- escapeRegExp.js | 2 +- test/{escapeRegExp.js => escapeRegExp.test.js} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename test/{escapeRegExp.js => escapeRegExp.test.js} (100%) diff --git a/escapeRegExp.js b/escapeRegExp.js index 503a103c7..6c77d42de 100644 --- a/escapeRegExp.js +++ b/escapeRegExp.js @@ -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 diff --git a/test/escapeRegExp.js b/test/escapeRegExp.test.js similarity index 100% rename from test/escapeRegExp.js rename to test/escapeRegExp.test.js