Files
klz-cables.com/.pnpm-store/v10/files/3a/6dda575df29dc826c8fafa45c6a99700c066fbf6f117a63d3f809d8234a2c84bcf87a3bcf8d7d9c7c7ee90dc0a97f974693c1d98dff7486df8700e3d564da7
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

46 lines
1.2 KiB
Plaintext

import parseRange from 'range-parser';
/**
* Parses HTTP Range header according to RFC 7233
*
* @returns Result object indicating whether to serve full file, partial content, or invalid range
*/ export function parseRangeHeader({ fileSize, rangeHeader }) {
// No Range header - serve full file
if (!rangeHeader) {
return {
type: 'full',
range: null
};
}
const result = parseRange(fileSize, rangeHeader);
// Invalid range syntax or unsatisfiable range
if (result === -1 || result === -2) {
return {
type: 'invalid',
range: null
};
}
// Must be bytes range type
if (result.type !== 'bytes' || result.length === 0) {
return {
type: 'invalid',
range: null
};
}
// Multi-range requests: use first range only (standard simplification)
const range = result[0];
if (!range) {
return {
type: 'invalid',
range: null
};
}
return {
type: 'partial',
range: {
end: range.end,
start: range.start
}
};
}
//# sourceMappingURL=parseRangeHeader.js.map