mirror of
https://github.com/badlogic/heissepreise.git
synced 2024-07-04 14: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) => {
|
exports.queryItems = (query, items, exactWord) => {
|
||||||
query = query.trim();
|
query = query.trim().replace(",", ".").toLowerCase();
|
||||||
if (query.length < 3) return [];
|
if (query.length < 3) return { items: [], queryTokens: [] };
|
||||||
let tokens = query.split(/\s+/).map((token) => token.toLowerCase().replace(",", "."));
|
const regex = /([A-Za-z-][A-Za-z0-9-]*)|(>=|<=|=|>|<)|(\d+(\.\d+)?)/g;
|
||||||
|
let tokens = query.match(regex);
|
||||||
|
|
||||||
// Find quantity/unit query
|
// Find quantity/unit query
|
||||||
let newTokens = [];
|
let newTokens = [];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user