Fix range header parsing

Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
automated-signal
2026-03-16 13:00:36 -05:00
committed by GitHub
parent 9e3fd1ed0c
commit 22177fa457

View File

@@ -791,15 +791,12 @@ function handleRangeRequest({
}
// Chromium only sends open-ended ranges: "start-"
type Match = RegExpMatchArray & { 1: string };
const match = range.match(/^bytes=(\d+)-$/);
if (match == null) {
if (match == null || match[1] == null) {
log.error(`invalid range header: ${range}`);
return create200Response();
}
const [startInput] = match as Match;
const startParam = safeParseInteger(startInput);
const startParam = safeParseInteger(match[1]);
if (startParam == null) {
log.error(`invalid range header: ${range}`);
return create200Response();