apostrophecms / apostrophe-elasticsearch

All text searches within Apostrophe are powered by Elasticsearch when this module is active.
3 stars 3 forks source link

fix undefined search string #8

Closed GiuseppeCM closed 5 years ago

GiuseppeCM commented 5 years ago

In case that you have defined a cursor with filter .search(string) and string is undefined, the server process crash.

boutell commented 5 years ago

Good catch, but does this fix the bug? undefined is falsy, so I would expect it to still crash.

A safer test would be if (s == null). Strangely enough, null is only == to undefined and itself, which is handy in this case. Anything else should coerce to a string OK.

boutell commented 5 years ago

Oh I see.

boutell commented 5 years ago

Thanks.