Describe the bug
geoStylerFilterToOlParserFilter in the switch statement, intermediate and restFilter are declared in the && case but used in the || case, this breaks if you only have an or filter.
offending code:
try {
if (isNestedFilter) {
switch (filter[0]) {
case '&&':
let intermediate = true;
let restFilter = filter.slice(1);
restFilter.forEach((f: Filter) => {
if (!this.geoStylerFilterToOlParserFilter(feature, f)) {
intermediate = false;
}
});
matchesFilter = intermediate;
break;
case '||':
intermediate = false;
restFilter = filter.slice(1);
restFilter.forEach((f: Filter) => {
if (this.geoStylerFilterToOlParserFilter(feature, f)) {
intermediate = true;
}
});
matchesFilter = intermediate;
break;
the fix is to declare the two vars outside of the switch scope:
try {
let intermediate: boolean;
let restFilter: any;
if (isNestedFilter) {
switch (filter[0]) {
case '&&':
intermediate = true;
restFilter = filter.slice(1);
restFilter.forEach((f: Filter) => {
if (!this.geoStylerFilterToOlParserFilter(feature, f)) {
intermediate = false;
}
});
matchesFilter = intermediate;
break;
case '||':
intermediate = false;
restFilter = filter.slice(1);
restFilter.forEach((f: Filter) => {
if (this.geoStylerFilterToOlParserFilter(feature, f)) {
intermediate = true;
}
});
matchesFilter = intermediate;
break;
To Reproduce
process a style with an or filter only, code will break, sample failing filter (test filter to catch all records and show issue(i know its nonsensical)
Bug
Describe the bug geoStylerFilterToOlParserFilter in the switch statement, intermediate and restFilter are declared in the && case but used in the || case, this breaks if you only have an or filter.
offending code:
the fix is to declare the two vars outside of the switch scope:
To Reproduce process a style with an or filter only, code will break, sample failing filter (test filter to catch all records and show issue(i know its nonsensical)
Expected behavior style to be processed without failure
I have created a PR at https://github.com/geostyler/geostyler-openlayers-parser/pull/796
thanks for the library