@zimic/interceptor 0.17.1-canary.0 → 0.17.1-canary.2
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.
- package/dist/cli.js +3 -4
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +3 -4
- package/dist/cli.mjs.map +1 -1
- package/dist/http.js +44 -11
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +44 -11
- package/dist/http.mjs.map +1 -1
- package/package.json +7 -7
- package/src/cli/browser/init.ts +2 -3
- package/src/http/requestHandler/HttpRequestHandlerClient.ts +1 -4
package/dist/http.mjs
CHANGED
|
@@ -423,17 +423,50 @@ var TimesCheckError = class extends TypeError {
|
|
|
423
423
|
};
|
|
424
424
|
var TimesCheckError_default = TimesCheckError;
|
|
425
425
|
|
|
426
|
-
// ../zimic-utils/dist/
|
|
427
|
-
async function blobContains(blob, otherBlob) {
|
|
428
|
-
return blob.type === otherBlob.type && blob.size >= otherBlob.size && (await blob.text()).includes(await otherBlob.text());
|
|
429
|
-
}
|
|
430
|
-
__name(blobContains, "blobContains");
|
|
431
|
-
__name2(blobContains, "blobContains");
|
|
432
|
-
var blobContains_default = blobContains;
|
|
433
|
-
|
|
434
|
-
// ../zimic-utils/dist/chunk-VXSYL3FX.mjs
|
|
426
|
+
// ../zimic-utils/dist/chunk-HBO3G76H.mjs
|
|
435
427
|
async function blobEquals(blob, otherBlob) {
|
|
436
|
-
|
|
428
|
+
if (blob.type !== otherBlob.type || blob.size !== otherBlob.size) {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
const reader = blob.stream().getReader();
|
|
432
|
+
const otherReader = otherBlob.stream().getReader();
|
|
433
|
+
let buffer = new Uint8Array(0);
|
|
434
|
+
let otherBuffer = new Uint8Array(0);
|
|
435
|
+
try {
|
|
436
|
+
while (true) {
|
|
437
|
+
await Promise.all([
|
|
438
|
+
buffer.length === 0 && reader.read().then((result) => {
|
|
439
|
+
if (!result.done) {
|
|
440
|
+
buffer = result.value;
|
|
441
|
+
}
|
|
442
|
+
}),
|
|
443
|
+
otherBuffer.length === 0 && otherReader.read().then((result) => {
|
|
444
|
+
if (!result.done) {
|
|
445
|
+
otherBuffer = result.value;
|
|
446
|
+
}
|
|
447
|
+
})
|
|
448
|
+
]);
|
|
449
|
+
const streamsEndedTogether = buffer.length === 0 && otherBuffer.length === 0;
|
|
450
|
+
if (streamsEndedTogether) {
|
|
451
|
+
return true;
|
|
452
|
+
}
|
|
453
|
+
const oneStreamEndedBeforeTheOther = buffer.length === 0 && otherBuffer.length > 0 || buffer.length > 0 && otherBuffer.length === 0;
|
|
454
|
+
if (oneStreamEndedBeforeTheOther) {
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
const minimumByteLength = Math.min(buffer.length, otherBuffer.length);
|
|
458
|
+
for (let byteIndex = 0; byteIndex < minimumByteLength; byteIndex++) {
|
|
459
|
+
if (buffer[byteIndex] !== otherBuffer[byteIndex]) {
|
|
460
|
+
return false;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
buffer = buffer.slice(minimumByteLength);
|
|
464
|
+
otherBuffer = otherBuffer.slice(minimumByteLength);
|
|
465
|
+
}
|
|
466
|
+
} finally {
|
|
467
|
+
reader.releaseLock();
|
|
468
|
+
otherReader.releaseLock();
|
|
469
|
+
}
|
|
437
470
|
}
|
|
438
471
|
__name(blobEquals, "blobEquals");
|
|
439
472
|
__name2(blobEquals, "blobEquals");
|
|
@@ -740,7 +773,7 @@ var HttpRequestHandlerClient = class {
|
|
|
740
773
|
diff: { expected: restrictionBody, received: body }
|
|
741
774
|
};
|
|
742
775
|
}
|
|
743
|
-
const matchesRestriction2 =
|
|
776
|
+
const matchesRestriction2 = await blobEquals_default(body, restrictionBody);
|
|
744
777
|
return matchesRestriction2 ? { value: true } : {
|
|
745
778
|
value: false,
|
|
746
779
|
diff: { expected: restrictionBody, received: body }
|