fix: avoid duplicated slash in connection url
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 25 Apr 2024 18:14:14 +0000 (20:14 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 25 Apr 2024 18:14:14 +0000 (20:14 +0200)
closes #1034

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
build-requirements.js
package.json
src/charging-station/ChargingStation.ts
ui/web/package.json

index f73e3e89c642fbb315175cfd586e178108d8ac37..c92b20953402121217bb38ed224222498cac1852 100644 (file)
@@ -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.
index f1b55722fecf4be98bffc281bb77504b5b435143..9ffb8b4f6c891a4b5f5640c3393f8bba930d51d7 100644 (file)
@@ -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",
index c31c00f7b49343b8b3f92f0e15daeb34e0b8c5ce..080349eae731cbe27e9ba6b00354da0d40a66f7e 100644 (file)
@@ -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}`
     )
   }
 
index 185fecb91c25eb6aacaff56b0ea0e4b69ff6ab0d..2002665d4544353fd04718bed5e10d30354c1857 100644 (file)
@@ -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",