fix: allowed ConcatenateJSON with empty input (#138)
This commit is contained in:
parent
55ec7d9dd2
commit
c45f03e144
2 changed files with 39 additions and 1 deletions
|
@ -29,6 +29,14 @@ func ConcatenateJSON(first, second []byte) ([]byte, error) {
|
|||
if !bytes.HasPrefix(second, []byte{'{'}) {
|
||||
return nil, fmt.Errorf("jws: invalid JSON %s", second)
|
||||
}
|
||||
// check empty
|
||||
if len(first) == 2 {
|
||||
return second, nil
|
||||
}
|
||||
if len(second) == 2 {
|
||||
return first, nil
|
||||
}
|
||||
|
||||
first[len(first)-1] = ','
|
||||
first = append(first, second[1:]...)
|
||||
return first, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue