Always treat filtered_* as full matches (#13083)

* Revert "update tests to use regex ^$ anchors"

This reverts commit 3d9bc552e9.

* utils: filterProperties should ensure full match
This commit is contained in:
Jorge Schrauwen authored and GitHub committed 2022-07-11 17:24:34 +02:00
1 parent 14216b7454
commit a0255d0f2c
3 files changed
+10 -10

No files matched your search

+3 -3
View File
@@ -8,9 +8,9 @@ import objectAssignDeep from 'object-assign-deep';
const saveInterval = 1000 * 60 * 5; // 5 minutes
const dontCacheProperties = [
'^action$', '^action_.*$', '^button$', '^button_left$', '^button_right$', '^click$', '^forgotten$', '^keyerror$',
'^step_size$', '^transition_time$', '^group_list$', '^group_capacity$', '^no_occupancy_since$',
'^step_mode$', '^transition_time$', '^duration$', '^elapsed$', '^from_side$', '^to_side$',
'action', 'action_.*', 'button', 'button_left', 'button_right', 'click', 'forgotten', 'keyerror',
'step_size', 'transition_time', 'group_list', 'group_capacity', 'no_occupancy_since',
'step_mode', 'transition_time', 'duration', 'elapsed', 'from_side', 'to_side',
];
class State {
+3 -3
View File
@@ -341,10 +341,10 @@ function publishLastSeen(data: eventdata.LastSeenChanged, settings: Settings, al
}
}
function filterProperties(filterRegex: string[], data: KeyValue): void {
if (filterRegex) {
function filterProperties(filter: string[], data: KeyValue): void {
if (filter) {
for (const property of Object.keys(data)) {
if (filterRegex.find((p) => property.match(p))) {
if (filter.find((p) => property.match(`^${p}$`))) {
delete data[property];
}
}