1
0
mirror of https://github.com/nitezs/sub2sing-box.git synced 2024-12-23 14:54:42 -05:00

add: url safe base64

This commit is contained in:
Nite07 2024-03-19 03:33:25 +08:00
parent 7f4ee70cb7
commit 7a5325187a

View File

@ -7,6 +7,11 @@ import (
func DecodeBase64(s string) (string, error) {
s = strings.TrimSpace(s)
// url safe
if strings.Contains(s, "-") || strings.Contains(s, "_") {
s = strings.Replace(s, "-", "+", -1)
s = strings.Replace(s, "_", "/", -1)
}
if len(s)%4 != 0 {
s += strings.Repeat("=", 4-len(s)%4)
}