@hkdigital/lib-sveltekit 0.1.103 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,8 +32,6 @@
|
|
32
32
|
* }
|
33
33
|
*/
|
34
34
|
|
35
|
-
import { HkPromise } from '../promise';
|
36
|
-
|
37
35
|
/** @typedef {import('./typedef').CacheEntry} CacheEntry */
|
38
36
|
|
39
37
|
/** @typedef {import('./typedef').IDBRequestEvent} IDBRequestEvent */
|
@@ -347,10 +345,18 @@ export default class IndexedDbCache {
|
|
347
345
|
return;
|
348
346
|
}
|
349
347
|
|
348
|
+
// Skip old entries or corrupted blobs
|
349
|
+
if (!entry.bodyType || entry.bodyType !== 'ab') {
|
350
|
+
// Delete old/corrupted entry
|
351
|
+
this._deleteEntry(key).catch(console.error);
|
352
|
+
resolve(null);
|
353
|
+
return;
|
354
|
+
}
|
355
|
+
|
350
356
|
// Clone Blob before reference becomes invalid
|
351
357
|
let responseBody = entry.body;
|
352
358
|
|
353
|
-
if (entry.bodyType === '
|
359
|
+
if (entry.bodyType === 'ab') {
|
354
360
|
// Reconstruct Blob from ArrayBuffer
|
355
361
|
responseBody = new Blob([entry.body], {
|
356
362
|
type: entry.contentType || 'application/octet-stream'
|
@@ -469,7 +475,7 @@ export default class IndexedDbCache {
|
|
469
475
|
|
470
476
|
// Extract response data - handle both browser Response and test mocks
|
471
477
|
let body;
|
472
|
-
let bodyType = '
|
478
|
+
let bodyType = 'ab'; // Default is ArrayBuffer
|
473
479
|
let contentType = '';
|
474
480
|
|
475
481
|
try {
|