From 7a57e5939639cbaa67f8baed2d6724366901490e Mon Sep 17 00:00:00 2001 From: uchenily Date: Sat, 28 Feb 2026 11:56:09 +0800 Subject: [PATCH] feat: Relax isValidBase64 to accept non-standard base64 subscription payloads --- frontend/src/utils/is.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/utils/is.ts b/frontend/src/utils/is.ts index c0ef3d0b..052d38ff 100644 --- a/frontend/src/utils/is.ts +++ b/frontend/src/utils/is.ts @@ -6,8 +6,20 @@ export const isValidBase64 = (str: string) => { if (str === '' || str.trim() === '') { return false } + + // Accept URL-safe base64 and ignore line breaks/spaces in subscription responses. + const normalized = str + .trim() + .replace(/\s+/g, '') + .replace(/-/g, '+') + .replace(/_/g, '/') + + const padding = (4 - (normalized.length % 4)) % 4 + const padded = normalized + '='.repeat(padding) + try { - return btoa(atob(str)) == str + atob(padded) + return true } catch { return false }