storage.js: Avoid to call JSON.parse with an empty string

IE11 seems not to like this..
This commit is contained in:
Johannes Meyer 2019-07-15 13:31:01 +02:00
parent 9561057b81
commit f11de266f4
1 changed files with 10 additions and 1 deletions

View File

@ -44,8 +44,17 @@
}
if (typeof Icinga.Storage.subscribers[event.key] !== 'undefined') {
var newValue = null,
oldValue = null;
if (event.newValue.length) {
newValue = JSON.parse(event.newValue);
}
if (event.oldValue.length) {
oldValue = JSON.parse(event.oldValue);
}
Icinga.Storage.subscribers[event.key].forEach(function (subscriber) {
subscriber[0].call(subscriber[1], JSON.parse(event.newValue), JSON.parse(event.oldValue), event);
subscriber[0].call(subscriber[1], newValue, oldValue, event);
});
}
});