@mswjs/interceptors
Advanced tools
Comparing version 0.13.3 to 0.13.4
@@ -59,3 +59,3 @@ "use strict"; | ||
window.fetch = function (input, init) { return __awaiter(void 0, void 0, void 0, function () { | ||
var ref, url, method, isoRequest, response, isomorphicResponse; | ||
var request, url, method, isoRequest, response, isomorphicResponse; | ||
var _a; | ||
@@ -65,5 +65,5 @@ return __generator(this, function (_b) { | ||
case 0: | ||
ref = new Request(input, init); | ||
request = new Request(input, init); | ||
url = typeof input === 'string' ? input : input.url; | ||
method = (init === null || init === void 0 ? void 0 : init.method) || 'GET'; | ||
method = request.method; | ||
debug('[%s] %s', method, url); | ||
@@ -74,6 +74,6 @@ _a = { | ||
method: method, | ||
headers: new headers_polyfill_1.Headers((init === null || init === void 0 ? void 0 : init.headers) || {}), | ||
credentials: (init === null || init === void 0 ? void 0 : init.credentials) || 'same-origin' | ||
headers: new headers_polyfill_1.Headers(request.headers), | ||
credentials: request.credentials | ||
}; | ||
return [4 /*yield*/, ref.text()]; | ||
return [4 /*yield*/, request.clone().text()]; | ||
case 1: | ||
@@ -85,3 +85,3 @@ isoRequest = (_a.body = _b.sent(), | ||
debug('awaiting for the mocked response...'); | ||
return [4 /*yield*/, resolver(isoRequest, ref)]; | ||
return [4 /*yield*/, resolver(isoRequest, request)]; | ||
case 2: | ||
@@ -101,3 +101,3 @@ response = _b.sent(); | ||
debug('no mocked response found, bypassing...'); | ||
return [2 /*return*/, pureFetch(input, init).then(function (response) { return __awaiter(void 0, void 0, void 0, function () { | ||
return [2 /*return*/, pureFetch(request).then(function (response) { return __awaiter(void 0, void 0, void 0, function () { | ||
var cloneResponse, _a, _b, _c; | ||
@@ -104,0 +104,0 @@ return __generator(this, function (_d) { |
{ | ||
"name": "@mswjs/interceptors", | ||
"description": "Low-level HTTP/HTTPS/XHR/fetch request interception library.", | ||
"version": "0.13.3", | ||
"version": "0.13.4", | ||
"main": "lib/index.js", | ||
@@ -54,3 +54,3 @@ "typings": "lib/index.d.ts", | ||
"jest": "^27.4.3", | ||
"node-fetch": "2.6.1", | ||
"node-fetch": "2.6.7", | ||
"page-with": "^0.5.1", | ||
@@ -57,0 +57,0 @@ "rimraf": "^3.0.2", |
@@ -23,5 +23,5 @@ import { | ||
window.fetch = async (input, init) => { | ||
const ref = new Request(input, init) | ||
const request = new Request(input, init) | ||
const url = typeof input === 'string' ? input : input.url | ||
const method = init?.method || 'GET' | ||
const method = request.method | ||
@@ -34,5 +34,5 @@ debug('[%s] %s', method, url) | ||
method: method, | ||
headers: new Headers(init?.headers || {}), | ||
credentials: init?.credentials || 'same-origin', | ||
body: await ref.text(), | ||
headers: new Headers(request.headers), | ||
credentials: request.credentials, | ||
body: await request.clone().text(), | ||
} | ||
@@ -43,3 +43,3 @@ debug('isomorphic request', isoRequest) | ||
debug('awaiting for the mocked response...') | ||
const response = await resolver(isoRequest, ref) | ||
const response = await resolver(isoRequest, request) | ||
debug('mocked response', response) | ||
@@ -64,3 +64,3 @@ | ||
return pureFetch(input, init).then(async (response) => { | ||
return pureFetch(request).then(async (response) => { | ||
const cloneResponse = response.clone() | ||
@@ -67,0 +67,0 @@ debug('original fetch performed', cloneResponse) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
277884