Allow optional spaces in Range header parsing
Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
1 parent
0431e648c8
commit
aa455d13cc
2 files changed
+8
-1
No files matched your search
@@ -928,6 +928,13 @@ describe("parseByteRangeHeader", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("tolerates optional whitespace around separators", () => {
|
||||
expect(parseByteRangeHeader("bytes = 0 - 9", 100)).toEqual({
|
||||
start: 0,
|
||||
end: 9,
|
||||
});
|
||||
});
|
||||
|
||||
it("parses case-insensitive byte-unit prefixes", () => {
|
||||
expect(parseByteRangeHeader("ByTeS=0-9", 100)).toEqual({
|
||||
start: 0,
|
||||
|
||||
+1
-1
@@ -661,7 +661,7 @@ export function parseByteRangeHeader(
|
||||
return "invalid";
|
||||
}
|
||||
|
||||
const match = rangeHeaderValue.trim().match(/^bytes=(\d*)-(\d*)$/i);
|
||||
const match = rangeHeaderValue.trim().match(/^bytes\s*=\s*(\d*)\s*-\s*(\d*)$/i);
|
||||
if (!match) {
|
||||
return "invalid";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user