From: Jérôme Benoit Date: Sat, 9 Dec 2023 20:08:44 +0000 (+0100) Subject: fix: avoid null exception at firmware upgrade X-Git-Tag: v1.2.30~30 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=77807350ac2a2c7fcdad5b06059981e1ae4baaca;p=e-mobility-charging-stations-simulator.git fix: avoid null exception at firmware upgrade Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index d6ca6874..5bc0ec9a 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1200,14 +1200,16 @@ export class ChargingStation extends EventEmitter { this.stationInfo.firmwareUpgrade?.versionUpgrade?.patternGroup ?? this.stationInfo.firmwareVersion?.split('.').length; const match = new RegExp(this.stationInfo.firmwareVersionPattern!) - .exec(this.stationInfo.firmwareVersion!)! - .slice(1, patternGroup! + 1); - const patchLevelIndex = match.length - 1; - match[patchLevelIndex] = ( - convertToInt(match[patchLevelIndex]) + - this.stationInfo.firmwareUpgrade!.versionUpgrade!.step! - ).toString(); - this.stationInfo.firmwareVersion = match?.join('.'); + .exec(this.stationInfo.firmwareVersion!) + ?.slice(1, patternGroup! + 1); + if (!isNullOrUndefined(match)) { + const patchLevelIndex = match!.length - 1; + match![patchLevelIndex] = ( + convertToInt(match![patchLevelIndex]) + + this.stationInfo.firmwareUpgrade!.versionUpgrade!.step! + ).toString(); + this.stationInfo.firmwareVersion = match!.join('.'); + } } this.saveStationInfo(); this.configuredSupervisionUrl = this.getConfiguredSupervisionUrl();