From 42ec65a2d0d6b0c42bda20bae83afbebc5bb97fe Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Fri, 19 Jun 2020 16:19:13 +0200 Subject: [PATCH] ignore underscore, hyphen and dot in match --- www/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/www/index.js b/www/index.js index 7562da4..e6082fb 100644 --- a/www/index.js +++ b/www/index.js @@ -165,12 +165,17 @@ function setupAutocompleteList(input, items, as_list, onbegin, onend) { // append the DIV element as a child of the autocomplete container: this.parentNode.appendChild(list); + function normalize(s) { + return s.toUpperCase().replace(/[-_.]/g, ' '); + } + + var match = normalize(value); var c = 0; for (var i = 0; i < items.length; i += 1) { var item = items[i]; // match - var j = item.toUpperCase().indexOf(value.toUpperCase()); + var j = normalize(item).indexOf(match); if (j < 0) { continue; } -- 2.30.2