Add B64decode expr helper (#2183)

This commit is contained in:
blotus 2023-05-04 14:15:20 +02:00 committed by GitHub
parent 8f71edaadd
commit a753ea6981
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 1 deletions

View file

@ -2,6 +2,7 @@ package exprhelpers
import (
"bufio"
"encoding/base64"
"fmt"
"net"
"net/url"
@ -585,3 +586,12 @@ func Match(params ...any) (any, error) {
}
return matched, nil
}
func B64Decode(params ...any) (any, error) {
encoded := params[0].(string)
decoded, err := base64.StdEncoding.DecodeString(encoded)
if err != nil {
return "", err
}
return string(decoded), nil
}