From 8cd82c275ae27f4159051bcb0e289ce3f534d6c9 Mon Sep 17 00:00:00 2001 From: Seongjae Lee Date: Sun, 20 Sep 2015 20:22:13 -0700 Subject: [PATCH] Tokenizer should return an empty array with an empty string --- lib/tokenizer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tokenizer.js b/lib/tokenizer.js index 8c55a0bb..19c90acb 100644 --- a/lib/tokenizer.js +++ b/lib/tokenizer.js @@ -15,6 +15,6 @@ lunr.tokenizer = function (obj) { if (!arguments.length || obj == null || obj == undefined) return [] if (Array.isArray(obj)) return obj.map(function (t) { return t.toLowerCase() }) - return obj.toString().trim().toLowerCase().split(/[\s\-]+/) + var str = obj.toString().trim().toLowerCase() + return str.length ? str.split(/[\s\-]+/) : [] } -