diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-04-19 18:11:53 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-04-19 18:11:53 -1000 |
commit | 7750ee481b305ff8789ca9813da2c62182b25b06 (patch) | |
tree | 5e39039ca4bb8569a87bc48f708683113deff8c9 /lib/app.js | |
parent | 644220073961892fb5fbd673e8c6aee488ba0ad6 (diff) | |
download | patchfoo-7750ee481b305ff8789ca9813da2c62182b25b06.tar.gz patchfoo-7750ee481b305ff8789ca9813da2c62182b25b06.zip |
Handle invalid regex
Diffstat (limited to 'lib/app.js')
-rw-r--r-- | lib/app.js | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -252,8 +252,16 @@ function forSome(each) { function filterByText(str) { if (!str) return function () { return true } - var search = new RegExp(str, 'i') - var matches = forSome(search.test.bind(search)) + var matcher + try { + var search = new RegExp(str, 'i') + matcher = search.test.bind(search) + } catch(e) { + matcher = function (value) { + return String(value).indexOf(str) !== -1 + } + } + var matches = forSome(matcher) return function (msg) { var c = msg.value.content return c && matches(c) |