From eafa66f45076b6dc850df9b52107cc3cdfe42f94 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Sat, 17 Jan 2026 16:08:56 +0100 Subject: [PATCH] fix: improve legacy session key handling by trimming whitespace --- public/script.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/script.js b/public/script.js index 2c68c6f..4d768e9 100644 --- a/public/script.js +++ b/public/script.js @@ -31,14 +31,15 @@ // * Use a static key for session storage to ensure consistency across pages const key = 'ciphera_session_id'; - // * Legacy key support for migration - const legacyKey = 'plausible_session_' + domain; + // * Legacy key support for migration (strip whitespace just in case) + const legacyKey = 'plausible_session_' + (domain ? domain.trim() : ''); try { + // * Try to get existing session ID cachedSessionId = sessionStorage.getItem(key); // * If not found in new key, try legacy key and migrate - if (!cachedSessionId) { + if (!cachedSessionId && legacyKey) { cachedSessionId = sessionStorage.getItem(legacyKey); if (cachedSessionId) { sessionStorage.setItem(key, cachedSessionId);