fix: base64 encoding on vmess/shadowsocks inbounds

This commit is contained in:
Shishkevich D. 2025-03-08 05:32:23 +00:00
parent 6658f648e6
commit 590c96bda0

View file

@ -515,17 +515,22 @@ class ClipboardManager {
class Base64 {
static encode(content = "", safe = false) {
if (safe) {
return window.btoa(content)
return Base64.encode(content)
.replace(/\+/g, '-')
.replace(/=/g, '')
.replace(/\//g, '_')
}
return window.btoa(content)
return window.btoa(
String.fromCharCode(...new TextEncoder().encode(content))
)
}
static decode(content = "") {
return window.atob(content)
return new TextDecoder()
.decode(
Uint8Array.from(window.atob(content), c => c.charCodeAt(0))
)
}
}