Skip to content

Commit 403425c

Browse files
author
Johan
committedMar 9, 2022
Fix exactMatch: "auto" comparisons
1 parent 09645ac commit 403425c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎src/fancyTable.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@
9292
// Exact match due to "quoted" value
9393
search = search.substring(1,search.length-1);
9494
return (data==search);
95-
} else if(settings.exactMatch == "auto" && search.replace(/\s+/g,"").match(/^[<>]/)){
95+
} else if(settings.exactMatch == "auto" && search.replace(/\s+/g,"").match(/^[<>]=?/)){
9696
// Less < or greater > than
97-
var comp = search.replace(/\s+/g,"").substring(0,1);
98-
var val = search.replace(/\s+/g,"").substring(1);
99-
return ((comp == '>' && data*1 > val*1) || (comp == '<' && data*1 < val*1))
97+
var comp = search.replace(/\s+/g,"").match(/^[<>]=?/)[0];
98+
var val = search.replace(/\s+/g,"").substring(comp.length);
99+
return ((comp == '>' && data*1 > val*1) || (comp == '<' && data*1 < val*1) || (comp == '>=' && data*1 >= val*1) || (comp == '<=' && data*1 <= val*1))
100100
} else if(settings.exactMatch == "auto" && search.replace(/\s+/g,"").match(/^.+(\.\.|-).+$/)){
101101
// Intervall 10..20 or 10-20
102102
var arr = search.replace(/\s+/g,"").split(/\.\.|-/);
103-
return (data*1 > arr[0]*1 && data*1 < arr[1]*1);
103+
return (data*1 >= arr[0]*1 && data*1 <= arr[1]*1);
104104
}
105105
return (settings.exactMatch === true) ? (data==search) : (new RegExp(search).test(data));
106106
};

0 commit comments

Comments
 (0)
Please sign in to comment.