Verified Commit b8514ef9 authored by Daniel Sonck's avatar Daniel Sonck
Browse files

Fix Cursor.Parse to return the embedded value

parent 469cd2e5
Pipeline #434 waiting for manual action with stages
in 4 minutes and 11 seconds
......@@ -26,19 +26,21 @@ func MakeCursor(prefix string, position int) Cursor {
}
func (after *Cursor) Parse(prefix string) (start int, err error) {
if after != nil {
cursor, err := base64.StdEncoding.DecodeString((string)(*after))
if err != nil {
return 0, fmt.Errorf("illegal cursor: %w", err)
}
if !strings.HasPrefix((string)(cursor), prefix+":") {
return 0, fmt.Errorf("illegal cursor")
}
start, err = strconv.Atoi((string)(cursor)[len(prefix)+1:])
if err!=nil {
return 0, fmt.Errorf("illegal cursor: %w", err)
}
if after == nil {
return -1, nil
}
return -1, nil
}
\ No newline at end of file
cursor, err := base64.StdEncoding.DecodeString((string)(*after))
if err != nil {
return 0, fmt.Errorf("illegal cursor: %w", err)
}
if !strings.HasPrefix((string)(cursor), prefix+":") {
return 0, fmt.Errorf("illegal cursor")
}
start, err = strconv.Atoi((string)(cursor)[len(prefix)+1:])
if err != nil {
return 0, fmt.Errorf("illegal cursor: %w", err)
}
return start, nil
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment