workbox-range-requests
Advanced tools
Comparing version 7.0.0 to 7.1.0
@@ -5,2 +5,3 @@ this.workbox = this.workbox || {}; | ||
// @ts-ignore | ||
try { | ||
@@ -27,3 +28,2 @@ self['workbox:range-requests:7.0.0'] && _(); | ||
*/ | ||
function calculateEffectiveBoundaries(blob, start, end) { | ||
@@ -37,5 +37,3 @@ { | ||
} | ||
const blobSize = blob.size; | ||
if (end && end > blobSize || start && start < 0) { | ||
@@ -48,9 +46,7 @@ throw new WorkboxError_js.WorkboxError('range-not-satisfiable', { | ||
} | ||
let effectiveStart; | ||
let effectiveEnd; | ||
if (start !== undefined && end !== undefined) { | ||
effectiveStart = start; // Range values are inclusive, so add 1 to the value. | ||
effectiveStart = start; | ||
// Range values are inclusive, so add 1 to the value. | ||
effectiveEnd = end + 1; | ||
@@ -64,3 +60,2 @@ } else if (start !== undefined && end === undefined) { | ||
} | ||
return { | ||
@@ -87,3 +82,2 @@ start: effectiveStart, | ||
*/ | ||
function parseRangeHeader(rangeHeader) { | ||
@@ -97,5 +91,3 @@ { | ||
} | ||
const normalizedRangeHeader = rangeHeader.trim().toLowerCase(); | ||
if (!normalizedRangeHeader.startsWith('bytes=')) { | ||
@@ -105,7 +97,6 @@ throw new WorkboxError_js.WorkboxError('unit-must-be-bytes', { | ||
}); | ||
} // Specifying multiple ranges separate by commas is valid syntax, but this | ||
} | ||
// Specifying multiple ranges separate by commas is valid syntax, but this | ||
// library only attempts to handle a single, contiguous sequence of bytes. | ||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range#Syntax | ||
if (normalizedRangeHeader.includes(',')) { | ||
@@ -116,5 +107,4 @@ throw new WorkboxError_js.WorkboxError('single-range-only', { | ||
} | ||
const rangeParts = /(\d*)-(\d*)/.exec(normalizedRangeHeader); // We need either at least one of the start or end values. | ||
const rangeParts = /(\d*)-(\d*)/.exec(normalizedRangeHeader); | ||
// We need either at least one of the start or end values. | ||
if (!rangeParts || !(rangeParts[1] || rangeParts[2])) { | ||
@@ -125,3 +115,2 @@ throw new WorkboxError_js.WorkboxError('invalid-range-values', { | ||
} | ||
return { | ||
@@ -158,3 +147,2 @@ start: rangeParts[1] === '' ? undefined : Number(rangeParts[1]), | ||
*/ | ||
async function createPartialResponse(request, originalResponse) { | ||
@@ -174,3 +162,2 @@ try { | ||
} | ||
if (originalResponse.status === 206) { | ||
@@ -181,9 +168,6 @@ // If we already have a 206, then just pass it through as-is; | ||
} | ||
const rangeHeader = request.headers.get('range'); | ||
if (!rangeHeader) { | ||
throw new WorkboxError_js.WorkboxError('no-range-header'); | ||
} | ||
const boundaries = parseRangeHeader(rangeHeader); | ||
@@ -213,3 +197,2 @@ const originalBlob = await originalResponse.blob(); | ||
} | ||
return new Response('', { | ||
@@ -238,3 +221,2 @@ status: 416, | ||
*/ | ||
class RangeRequestsPlugin { | ||
@@ -261,10 +243,8 @@ constructor() { | ||
return await createPartialResponse(request, cachedResponse); | ||
} // If there was no Range: header, or if cachedResponse wasn't valid, just | ||
} | ||
// If there was no Range: header, or if cachedResponse wasn't valid, just | ||
// pass it through as-is. | ||
return cachedResponse; | ||
}; | ||
} | ||
} | ||
@@ -277,3 +257,3 @@ | ||
}({}, workbox.core._private, workbox.core._private, workbox.core._private)); | ||
})({}, workbox.core._private, workbox.core._private, workbox.core._private); | ||
//# sourceMappingURL=workbox-range-requests.dev.js.map |
{ | ||
"name": "workbox-range-requests", | ||
"version": "7.0.0", | ||
"version": "7.1.0", | ||
"license": "MIT", | ||
@@ -29,5 +29,5 @@ "author": "Google's Web DevRel Team", | ||
"dependencies": { | ||
"workbox-core": "7.0.0" | ||
"workbox-core": "7.1.0" | ||
}, | ||
"gitHead": "c1d11636823e5e3a89520f7a531970a39304b14a" | ||
"gitHead": "9e69c4269c35e2db9fbba4d13e4e6206c7b66d2a" | ||
} |
// @ts-ignore | ||
try{self['workbox:range-requests:7.0.0']&&_()}catch(e){} | ||
try{self['workbox:range-requests:7.1.0']&&_()}catch(e){} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
95184
846
+ Addedworkbox-core@7.1.0(transitive)
- Removedworkbox-core@7.0.0(transitive)
Updatedworkbox-core@7.1.0