From: Jérôme Benoit Date: Thu, 25 Apr 2024 18:14:14 +0000 (+0200) Subject: fix: avoid duplicated slash in connection url X-Git-Tag: v1.3.3~5 X-Git-Url: https://git.piment-noir.org/?p=e-mobility-charging-stations-simulator.git;a=commitdiff_plain;h=8fa6f565c86b72f3d6f040d283da83740a51542e fix: avoid duplicated slash in connection url closes #1034 Signed-off-by: Jérôme Benoit --- diff --git a/build-requirements.js b/build-requirements.js index f73e3e89..c92b2095 100644 --- a/build-requirements.js +++ b/build-requirements.js @@ -1,7 +1,9 @@ import chalk from 'chalk' import { satisfies } from 'semver' -import packageJson from './package.json' assert { type: 'json' } import { version, exit } from 'node:process' +import { readFileSync } from 'node:fs' + +const packageJson = JSON.parse(readFileSync('./package.json', 'utf8')) /** * Check if the current node version match the required engines version. diff --git a/package.json b/package.json index f1b55722..9ffb8b4f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "pnpm": ">=9.0.0" }, "volta": { - "node": "20.12.2", + "node": "22.0.0", "pnpm": "9.0.6" }, "packageManager": "pnpm@9.0.6", diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index c31c00f7..080349ea 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -261,14 +261,15 @@ export class ChargingStation extends EventEmitter { } public get wsConnectionUrl (): URL { + const wsConnectionBaseUrlStr = `${ + this.stationInfo?.supervisionUrlOcppConfiguration === true && + isNotEmptyString(this.stationInfo.supervisionUrlOcppKey) && + isNotEmptyString(getConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey)?.value) + ? getConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey)?.value + : this.configuredSupervisionUrl.href + }` return new URL( - `${ - this.stationInfo?.supervisionUrlOcppConfiguration === true && - isNotEmptyString(this.stationInfo.supervisionUrlOcppKey) && - isNotEmptyString(getConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey)?.value) - ? getConfigurationKey(this, this.stationInfo.supervisionUrlOcppKey)?.value - : this.configuredSupervisionUrl.href - }/${this.stationInfo?.chargingStationId}` + `${wsConnectionBaseUrlStr}${!wsConnectionBaseUrlStr.endsWith('/') ? '/' : ''}${this.stationInfo?.chargingStationId}` ) } diff --git a/ui/web/package.json b/ui/web/package.json index 185fecb9..2002665d 100644 --- a/ui/web/package.json +++ b/ui/web/package.json @@ -8,7 +8,7 @@ "pnpm": ">=9.0.0" }, "volta": { - "node": "20.12.2", + "node": "22.0.0", "pnpm": "9.0.6" }, "packageManager": "pnpm@9.0.6",