Skip to content

Commit

Permalink
SplitXXXX functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Daisuke Maki committed Oct 24, 2024
1 parent 0641cbd commit 4b140bf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions jws/jws.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ func parseJSON(data []byte) (result *Message, err error) {
func SplitCompact(src []byte) ([]byte, []byte, []byte, error) {
parts := bytes.Split(src, []byte("."))
if len(parts) < 3 {
return nil, nil, nil, fmt.Errorf(`invalid number of segments`)
return nil, nil, nil, parseerr(`invalid number of segments`)
}
return parts[0], parts[1], parts[2], nil
}
Expand All @@ -629,7 +629,7 @@ func SplitCompact(src []byte) ([]byte, []byte, []byte, error) {
func SplitCompactString(src string) ([]byte, []byte, []byte, error) {
parts := strings.Split(src, ".")
if len(parts) < 3 {
return nil, nil, nil, fmt.Errorf(`invalid number of segments`)
return nil, nil, nil, parseerr(`invalid number of segments`)
}
return []byte(parts[0]), []byte(parts[1]), []byte(parts[2]), nil
}
Expand All @@ -655,7 +655,7 @@ func SplitCompactReader(rdr io.Reader) ([]byte, []byte, []byte, error) {
n, err := rdr.Read(buf)
// return on unexpected read error
if err != nil && err != io.EOF {
return nil, nil, nil, fmt.Errorf(`unexpected end of input: %w`, err)
return nil, nil, nil, parseerr(`unexpected end of input: %w`, err)
}

// append to current buffer
Expand Down Expand Up @@ -698,7 +698,7 @@ func SplitCompactReader(rdr io.Reader) ([]byte, []byte, []byte, error) {
}
}
if periods != 2 {
return nil, nil, nil, fmt.Errorf(`invalid number of segments`)
return nil, nil, nil, parseerr(`invalid number of segments`)
}

return protected, payload, signature, nil
Expand Down

0 comments on commit 4b140bf

Please sign in to comment.