summaryrefslogtreecommitdiff
path: root/assets/js/mumi.js
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2023-01-01 23:15:33 +0100
committerRicardo Wurmus <rekado@elephly.net>2023-01-01 23:15:33 +0100
commitaa73af23eecac506144eda56a905d9a5fa42f6a3 (patch)
tree3800be294695172240e99f81c6a5e4c2da93e532 /assets/js/mumi.js
parent86f5796a23e12aa9aaf2ec5901d35683d6c60022 (diff)
js: Simplify query tokenizer.
Diffstat (limited to 'assets/js/mumi.js')
-rw-r--r--assets/js/mumi.js42
1 files changed, 1 insertions, 41 deletions
diff --git a/assets/js/mumi.js b/assets/js/mumi.js
index dde30a6..ab29f08 100644
--- a/assets/js/mumi.js
+++ b/assets/js/mumi.js
@@ -26,48 +26,8 @@ var mumi = (function () {
{ text: 'severity:serious' },
{ text: 'severity:wishlist' },
];
- const queryTokenizer = {
- [Symbol.split](str) {
- let phrase = false;
- let phrasePos = 0;
- let pos = 0;
- const result = [];
- while (pos < str.length) {
- let matchPos = str.substring(pos).search(/(\s|\")/);
- if (matchPos === -1) {
- result.push(str.substring(pos));
- break;
- }
-
- matchPos += pos;
- let char = str.charAt(matchPos);
- let begin = pos;
-
- if (char === '"') {
- if (phrase) {
- /* finished phrase, record from beginning */
- phrase = false;
- begin = phrasePos;
- matchPos += 1;
- } else {
- /* beginning phrase, remember position */
- phrase = true;
- phrasePos = matchPos;
- }
- }
-
- /* don't push anything while inside a phrase */
- if (!phrase) {
- result.push(str.substring(begin, matchPos));
- }
- pos = matchPos + 1;
- }
- return result;
- },
- };
-
var tokenizeText = function (input, options, tokenInput) {
- let items = input.value.split(queryTokenizer).filter(entry => entry.trim() != '');
+ let items = input.value.match(/(\S+:)?"[^"]*"|\S+/g);
let tokens = [];
for (item of items) {
if (possibleTokens.find(element => element.text == item)) {