mirror of
https://github.com/badlogic/heissepreise.git
synced 2024-06-28 11:25:50 +02:00
Fix query parser, allow smushing parts of quantity queries together without whitespace.
This commit is contained in:
parent
362864761b
commit
7578f544db
|
@ -120,9 +120,10 @@ exports.queryItemsAlasql = (query, items) => {
|
|||
};
|
||||
|
||||
exports.queryItems = (query, items, exactWord) => {
|
||||
query = query.trim();
|
||||
if (query.length < 3) return [];
|
||||
let tokens = query.split(/\s+/).map((token) => token.toLowerCase().replace(",", "."));
|
||||
query = query.trim().replace(",", ".").toLowerCase();
|
||||
if (query.length < 3) return { items: [], queryTokens: [] };
|
||||
const regex = /([A-Za-z-][A-Za-z0-9-]*)|(>=|<=|=|>|<)|(\d+(\.\d+)?)/g;
|
||||
let tokens = query.match(regex);
|
||||
|
||||
// Find quantity/unit query
|
||||
let newTokens = [];
|
||||
|
|
Loading…
Reference in New Issue
Block a user