From: Moritz Warning Date: Fri, 19 Jun 2020 14:19:13 +0000 (+0200) Subject: ignore underscore, hyphen and dot in match X-Git-Tag: v2.2.2~7 X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=42ec65a2d0d6b0c42bda20bae83afbebc5bb97fe;p=web%2Ffirmware-selector-openwrt-org.git ignore underscore, hyphen and dot in match --- 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; }