[BUG]: Filtering on event data with language like summary is not possible
CDaxi opened this issue · 1 comments
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Use for example this calendar:
https://abfuhrtermine.awp-paf.de/WasteManagementPfaffenhofen/WasteManagementServiceServlet?ApplicationName=Calendar&SubmitAction=sync&StandortID=165472001&AboID=284378&Fra=RM;B;P;S
It contains for example SUMMARY;LANGUAGE=de:Restmuell
or DESCRIPTION;LANGUAGE=de:Bitte stellen Sie die Behälter bis 6:00 Uhr zur Abholung bereit.
.
If you configure the filterProperty to "summary", the summary attribute contains an object like:
{
"params": {
"LANGUAGE": "de"
},
"val": "Restmuell "
}
This is the reason why the regex filter can not work, it is no string, it is an object.
Expected behavior
If the property is an object and contains a key "val", use this attribute for filtering.
Lines 438 to 446 in e186020
can be changed to something like:
if (Array.isArray(filterProperty)) {
for (const prop of filterProperty) {
if (regex.test(prop)) {
return true;
}
}
} else if (typeof filterProperty === 'object' && 'val' in filterProperty) {
return regex.test(filterProperty.val);
} else {
return regex.test(filterProperty);
}
This code is not tested, but should work.
The issue was found while using node-red-contrib-ical-events.