| 2276 | } |
| 2277 | |
| 2278 | func decodeBlameCursor(cursor string) (int, error) { |
| 2279 | if cursor == "" { |
| 2280 | return 0, nil |
| 2281 | } |
| 2282 | |
| 2283 | decoded, err := base64.RawURLEncoding.DecodeString(cursor) |
| 2284 | if err != nil { |
| 2285 | return 0, fmt.Errorf("after cursor is invalid") |
| 2286 | } |
| 2287 | |
| 2288 | value := string(decoded) |
| 2289 | if !strings.HasPrefix(value, blameCursorPrefix) { |
| 2290 | return 0, fmt.Errorf("after cursor is invalid") |
| 2291 | } |
| 2292 | |
| 2293 | offset, err := strconv.Atoi(strings.TrimPrefix(value, blameCursorPrefix)) |
| 2294 | if err != nil || offset < 0 { |
| 2295 | return 0, fmt.Errorf("after cursor is invalid") |
| 2296 | } |
| 2297 | |
| 2298 | return offset, nil |
| 2299 | } |
| 2300 | |
| 2301 | // BlameAuthor describes the author of a commit referenced by a BlameRange. |
| 2302 | type BlameAuthor struct { |