Skip to content

Commit bb44d78

Browse files
committed
Change filtering syntax to be simpler
1 parent 52e3d8c commit bb44d78

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

website/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@
216216
</div>
217217
<div class="control" id="filterContainer" hidden>
218218
<input class="input" type="text" id="filter" name="filter"
219-
title='GitHub style syntax, with some aliases like "a" for "ahead", "d" for the date, etc. (see https://docs.github.com/en/search-github/getting-started-with-searching-on-github/about-searching-on-github)'
220-
placeholder="Type your filter here. eg: ahead:>=1 behind:<5" />
219+
title='There are aliases too (e.g. "a" for "ahead", "d" for the date, etc.). There is an implicit AND boolean operator in between each filter.'
220+
placeholder="Type your filter here. eg: ahead>=1 behind<5" />
221221
</div>
222222
</div>
223223
</div>

website/src/queries-logic.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,14 @@ function updateFilterFunction() {
327327
const conditionStrList = filter.split(' ');
328328
let conditionObj = {};
329329
for (const condition of conditionStrList) {
330-
let [attribute, requirement] = condition.split(':');
331-
if (!attribute || !requirement) {
332-
continue; // invalid condition
333-
}
334-
const [_, operator, value] = requirement.split(/([<>=]+)/);
335-
if (!operator || !value) {
330+
const attributeRgx = '([a-z]+)';
331+
const operatorRgx = '(<=|>=|[<=>])';
332+
const valueRgx = '([0-9]{4}-[0-9]{2}-[0-9]{2}|[0-9]+)';
333+
const regex = new RegExp(attributeRgx + operatorRgx + valueRgx);
334+
335+
const matchResult = condition.match(regex);
336+
let [attribute, operator, value] = matchResult ? matchResult.slice(1) : [];
337+
if (!attribute || !operator || !value) {
336338
continue; // invalid condition
337339
}
338340
if (attribute in mapTable) {

0 commit comments

Comments
 (0)