Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion frontend/src/utils/is.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down