in pkg/context/context.go [115:139]
func RangeStartIndex(rangeValue string) (int64, error) {
if rangeValue == "" {
return 0, errors.New("no range header")
}
// split the range value by "="
parts := strings.Split(rangeValue, "=")
if len(parts) != 2 || parts[0] != "bytes" {
return 0, errors.New("invalid range format")
}
// split the byte range by "-"
ranges := strings.Split(parts[1], "-")
if len(ranges) != 2 {
return 0, errors.New("invalid range format")
}
// convert the start index to an integer
startIndex, err := strconv.Atoi(ranges[0])
if err != nil {
return 0, err
}
return int64(startIndex), nil
}