git ssb

16+

cel / patchfoo



Commit 7750ee481b305ff8789ca9813da2c62182b25b06

Handle invalid regex

cel committed on 4/20/2019, 4:11:53 AM
Parent: 644220073961892fb5fbd673e8c6aee488ba0ad6

Files changed

lib/app.jschanged
lib/app.jsView
@@ -251,10 +251,18 @@
251251 }
252252
253253 function filterByText(str) {
254254 if (!str) return function () { return true }
255- var search = new RegExp(str, 'i')
256- var matches = forSome(search.test.bind(search))
255 + var matcher
256 + try {
257 + var search = new RegExp(str, 'i')
258 + matcher = search.test.bind(search)
259 + } catch(e) {
260 + matcher = function (value) {
261 + return String(value).indexOf(str) !== -1
262 + }
263 + }
264 + var matches = forSome(matcher)
257265 return function (msg) {
258266 var c = msg.value.content
259267 return c && matches(c)
260268 }

Built with git-ssb-web