From 16593408981d59e1bd3ad4de14071f45a8116d81 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 23 Nov 2019 21:48:24 -0500 Subject: Add support for prefix wildcards --- ext/bg/js/search.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ext/bg/js/search.js') diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index d2e0fd56..67a78075 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -207,10 +207,14 @@ class DisplaySearch extends Display { async onSearchQueryUpdated(query, animate) { try { const details = {}; - const match = /[*\uff0a]+$/.exec(query); + const match = /^([*\uff0a]*)([\w\W]*?)([*\uff0a]*)$/.exec(query); if (match !== null) { - details.wildcard = true; - query = query.substring(0, query.length - match[0].length); + if (match[1]) { + details.wildcard = 'prefix'; + } else if (match[3]) { + details.wildcard = 'suffix'; + } + query = match[2]; } const valid = (query.length > 0); -- cgit v1.2.3