From 5e077a10785d2c8b6e60263f376fd2a270d431da Mon Sep 17 00:00:00 2001 From: Etienne Samson Date: Tue, 1 Oct 2024 15:48:50 +0200 Subject: [PATCH] Fix a bug with season not loading stats --- src/pushStats/apiFunctions.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/pushStats/apiFunctions.js b/src/pushStats/apiFunctions.js index cde44f9..33c78bf 100644 --- a/src/pushStats/apiFunctions.js +++ b/src/pushStats/apiFunctions.js @@ -77,16 +77,26 @@ function getRequestOptions(info, path, method = 'GET', body = {}) { 'Content-Length': Buffer.byteLength(JSON.stringify(body)), }; + const slashPos = info.host.indexOf('/'); + let realPath = path; + let realHost = info.host; + if (slashPos !== -1) { + let hostPath = info.host.substring(slashPos + 1); + if (hostPath[hostPath.length - 1] !== '/' && path[0] !== '/') hostPath += '/'; + realPath = hostPath + path; + realHost = info.host.substring(0, slashPos); + } + if (info.username) headers['X-Username'] = info.username; if (info.token) headers['X-Token'] = info.token; return { - host: info.host, + host: realHost, port: info.port, - path, + path: realPath, method, headers, body, - isHTTPS: info.type === 'mmo', + isHTTPS: info.type === 'mmo' || info.type === 'season', }; }