From 210b00c98cc540d106a8aa2e5e0e7dd4fdf228a0 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Fri, 18 Jun 2021 21:20:28 -0700 Subject: [PATCH] fix(query): ignore empty tokens Empty tokens should not make it this far into the query code, but it can happen. In that case, we should ignore empty tokens and avoid aggrivating the `VariableStore` checks by attempting to store empty strings. This fixes the 500 erro described in https://github.com/pelias/api/issues/1535, but doesn't really fix the underlying problem. From my investigation it looks like Emoji that include tokens like a [variation selector](https://emojipedia.org/variation-selector-16/) will not be completely removed by the Pelias Parser (the emoji codepoint will be removed, but not the variation selector). --- query/view/admin_multi_match_first.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/query/view/admin_multi_match_first.js b/query/view/admin_multi_match_first.js index bcecd1387..3d7e3ac60 100644 --- a/query/view/admin_multi_match_first.js +++ b/query/view/admin_multi_match_first.js @@ -20,7 +20,7 @@ module.exports = function (adminFields) { // the actual query text is simply taken from the first valid admin field // this assumes all the values would be the same, which is probably not true // TODO: handle the case where not all admin area input values are the same - var tokens = vs.var('input:' + valid_admin_properties[0]).get().split(/\s+/g); + var tokens = vs.var('input:' + valid_admin_properties[0]).get().split(/\s+/g).filter(t => t.length > 0); // no valid tokens to use, fail now, don't render this view. if (!tokens || tokens.length < 2) { return null; }