mirror of https://github.com/golang-jwt/jwt.git
Merge branch 'fixBase64PaddingInGo13rc1' of github.com:cryptix/jwt-go
This commit is contained in:
commit
b1c2dab94c
8
jwt.go
8
jwt.go
|
@ -217,12 +217,8 @@ func EncodeSegment(seg []byte) string {
|
||||||
|
|
||||||
// Decode JWT specific base64url encoding with padding stripped
|
// Decode JWT specific base64url encoding with padding stripped
|
||||||
func DecodeSegment(seg string) ([]byte, error) {
|
func DecodeSegment(seg string) ([]byte, error) {
|
||||||
// len % 4
|
if l := len(seg) % 4; l > 0 {
|
||||||
switch len(seg) % 4 {
|
seg += strings.Repeat("=", 4-l)
|
||||||
case 2:
|
|
||||||
seg = seg + "=="
|
|
||||||
case 3:
|
|
||||||
seg = seg + "==="
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return base64.URLEncoding.DecodeString(seg)
|
return base64.URLEncoding.DecodeString(seg)
|
||||||
|
|
Loading…
Reference in New Issue