From 893a1cca43941062cab6b62dfd8e0f66247ac6bf Mon Sep 17 00:00:00 2001 From: amd64fox <62529699+amd64fox@users.noreply.github.com> Date: Fri, 2 Oct 2026 03:13:33 +0300 Subject: [PATCH] fix(js-helper): encode spotify app versions correctly --- js-helper/checkVersion.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/js-helper/checkVersion.js b/js-helper/checkVersion.js index 5f2b792..0d47a53 100644 --- a/js-helper/checkVersion.js +++ b/js-helper/checkVersion.js @@ -113,14 +113,18 @@ return ""; } - const parts = shortVersion.split("."); - if (parts.length !== 4) { + if (typeof shortVersion !== "string" || !/^\d+\.\d+\.\d+\.\d+$/.test(shortVersion)) { console.warn(`Invalid Spotify version format (${sourceLabel}):`, shortVersion); return ""; } - const [major, minor, patch, build] = parts; - return major + minor + patch + "0".repeat(Math.max(0, 7 - patch.length - build.length)) + build; + const [major, minor, patch, build] = shortVersion.split(".").map(Number); + const appVersion = major * 100000000 + minor * 10000000 + patch * 100000 + build; + if (!Number.isSafeInteger(appVersion) || minor > 9 || patch > 99 || build > 99999) { + console.warn(`Unsupported Spotify version (${sourceLabel}):`, shortVersion); + return ""; + } + return String(appVersion); } async function fetchJsonWithTimeout(url, timeoutMs) {