From 99ff962e95c7d51c3de807133a9f800d46dcbe1a Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Tue, 8 Nov 2022 09:09:03 +0100 Subject: [PATCH] fix wso2BaseUrl ends with / --- src/index.js | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/index.js b/src/index.js index cd15b06..1340b20 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,7 @@ const { addData, errors, } = require('cozy-konnector-libs') +const path = require('node:path') const soapRequest = require('easy-soap-request') const moment = require('moment') require('moment-timezone') @@ -276,25 +277,17 @@ async function deleteConsent( */ async function gatherData(baseUrl, apiAuthKey, sgeLogin, pointId) { log('info', 'Querying data...') + const measuresUrl = new URL( + path.resolve( + new URL(baseUrl).pathname, + '/enedis_SGE_ConsultationMesuresDetaillees/1.0' + ), + baseUrl + ).href await getContractStartDate(baseUrl, apiAuthKey, sgeLogin, pointId) - await getData( - `${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees/1.0`, - apiAuthKey, - sgeLogin, - pointId - ) - await getMaxPowerData( - `${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees/1.0`, - apiAuthKey, - sgeLogin, - pointId - ) - await getDataHalfHour( - `${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees/1.0`, - apiAuthKey, - sgeLogin, - pointId - ) + await getData(measuresUrl, apiAuthKey, sgeLogin, pointId) + await getMaxPowerData(measuresUrl, apiAuthKey, sgeLogin, pointId) + await getDataHalfHour(measuresUrl, apiAuthKey, sgeLogin, pointId) log('info', 'Querying data: done') } -- GitLab