From 710ee69418a4690e30f2cadcbe1511cadf49661e Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 4 Jul 2017 17:32:07 +0100 Subject: [PATCH] Don't try to match with an empty query string This was causing UserProvider to give results because every string happens to start with empty string and its regex also acepts the empty string. --- src/autocomplete/QueryMatcher.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/autocomplete/QueryMatcher.js b/src/autocomplete/QueryMatcher.js index f85d518fee..07398e7a5f 100644 --- a/src/autocomplete/QueryMatcher.js +++ b/src/autocomplete/QueryMatcher.js @@ -86,6 +86,9 @@ export default class QueryMatcher { if (this.options.shouldMatchWordsOnly) { query = query.replace(/[^\w]/g, ''); } + if (query.length === 0) { + return []; + } const results = []; this.keyMap.keys.forEach((key) => { let resultKey = key.toLowerCase();