msw 2.7.2 → 2.7.4
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/README.md +45 -80
- package/lib/core/{GraphQLHandler-D4_CxZQj.d.mts → GraphQLHandler-BNMGdWQe.d.mts} +1 -0
- package/lib/core/{GraphQLHandler-Pox7fIFM.d.ts → GraphQLHandler-D1CSV926.d.ts} +1 -0
- package/lib/core/graphql.d.mts +1 -1
- package/lib/core/graphql.d.ts +1 -1
- package/lib/core/handlers/GraphQLHandler.d.mts +1 -1
- package/lib/core/handlers/GraphQLHandler.d.ts +1 -1
- package/lib/core/handlers/GraphQLHandler.js.map +1 -1
- package/lib/core/handlers/GraphQLHandler.mjs.map +1 -1
- package/lib/core/index.d.mts +2 -1
- package/lib/core/index.d.ts +2 -1
- package/lib/core/index.js +2 -0
- package/lib/core/index.js.map +1 -1
- package/lib/core/index.mjs +2 -0
- package/lib/core/index.mjs.map +1 -1
- package/lib/core/isCommonAssetRequest.d.mts +20 -0
- package/lib/core/isCommonAssetRequest.d.ts +20 -0
- package/lib/core/isCommonAssetRequest.js +42 -0
- package/lib/core/isCommonAssetRequest.js.map +1 -0
- package/lib/core/isCommonAssetRequest.mjs +22 -0
- package/lib/core/isCommonAssetRequest.mjs.map +1 -0
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +1 -1
- package/lib/core/utils/request/onUnhandledRequest.js +3 -3
- package/lib/core/utils/request/onUnhandledRequest.js.map +1 -1
- package/lib/core/utils/request/onUnhandledRequest.mjs +3 -3
- package/lib/core/utils/request/onUnhandledRequest.mjs.map +1 -1
- package/lib/core/utils/url/getAbsoluteUrl.js +1 -1
- package/lib/core/utils/url/getAbsoluteUrl.js.map +1 -1
- package/lib/core/utils/url/getAbsoluteUrl.mjs +1 -1
- package/lib/core/utils/url/getAbsoluteUrl.mjs.map +1 -1
- package/lib/iife/index.js +24 -4
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +1 -1
- package/src/browser/utils/getAbsoluteWorkerUrl.test.ts +1 -3
- package/src/core/handlers/GraphQLHandler.ts +1 -0
- package/src/core/index.ts +1 -0
- package/src/core/isCommonAssetRequest.ts +45 -0
- package/src/core/utils/request/onUnhandledRequest.test.ts +65 -10
- package/src/core/utils/request/onUnhandledRequest.ts +6 -10
- package/src/core/utils/url/getAbsoluteUrl.test.ts +29 -11
- package/src/core/utils/url/getAbsoluteUrl.ts +1 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/isCommonAssetRequest.ts"],"sourcesContent":["/**\n * Determines if the given request is a static asset request.\n * Useful when deciding which unhandled requests to ignore.\n * @note Despite being ignored, you can still intercept and mock\n * static assets by creating request handlers for them.\n *\n * @example\n * import { isCommonAssetRequest } from 'msw'\n *\n * await worker.start({\n * onUnhandledRequest(request, print) {\n * if (!isCommonAssetRequest(request)) {\n * print.warning()\n * }\n * }\n * })\n */\nexport function isCommonAssetRequest(request: Request): boolean {\n const url = new URL(request.url)\n\n // Ignore certain protocols.\n if (url.protocol === 'file:') {\n return true\n }\n\n // Ignore static assets hosts.\n if (/(fonts\\.googleapis\\.com)/.test(url.hostname)) {\n return true\n }\n\n // Ignore node modules served over HTTP.\n if (/node_modules/.test(url.pathname)) {\n return true\n }\n\n // Ignore internal Vite requests, like \"/@vite/client\".\n if (url.pathname.includes('@vite')) {\n return true\n }\n\n // Ignore common static assets.\n return /\\.(s?css|less|m?jsx?|m?tsx?|html|ttf|otf|woff|woff2|eot|gif|jpe?g|png|avif|webp|svg|mp4|webm|ogg|mov|mp3|wav|ogg|flac|aac|pdf|txt|csv|json|xml|md|zip|tar|gz|rar|7z)$/i.test(\n url.pathname,\n )\n}\n"],"mappings":"AAiBO,SAAS,qBAAqB,SAA2B;AAC9D,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAG/B,MAAI,IAAI,aAAa,SAAS;AAC5B,WAAO;AAAA,EACT;AAGA,MAAI,2BAA2B,KAAK,IAAI,QAAQ,GAAG;AACjD,WAAO;AAAA,EACT;AAGA,MAAI,eAAe,KAAK,IAAI,QAAQ,GAAG;AACrC,WAAO;AAAA,EACT;AAGA,MAAI,IAAI,SAAS,SAAS,OAAO,GAAG;AAClC,WAAO;AAAA,EACT;AAGA,SAAO,yKAAyK;AAAA,IAC9K,IAAI;AAAA,EACN;AACF;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-
|
|
2
|
+
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-BNMGdWQe.mjs';
|
|
3
3
|
import '../../HttpResponse-BRDnWbjc.mjs';
|
|
4
4
|
import '@mswjs/interceptors';
|
|
5
5
|
import './isIterable.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-
|
|
2
|
+
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-D1CSV926.js';
|
|
3
3
|
import '../../HttpResponse-Cy7ytzUn.js';
|
|
4
4
|
import '@mswjs/interceptors';
|
|
5
5
|
import './isIterable.js';
|
|
@@ -23,6 +23,7 @@ __export(onUnhandledRequest_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(onUnhandledRequest_exports);
|
|
24
24
|
var import_toPublicUrl = require("./toPublicUrl.js");
|
|
25
25
|
var import_devUtils = require("../internal/devUtils.js");
|
|
26
|
+
var import_isCommonAssetRequest = require("../../isCommonAssetRequest.js");
|
|
26
27
|
async function onUnhandledRequest(request, strategy = "warn") {
|
|
27
28
|
const url = new URL(request.url);
|
|
28
29
|
const publicUrl = (0, import_toPublicUrl.toPublicUrl)(url) + url.search;
|
|
@@ -68,9 +69,8 @@ Read more: https://mswjs.io/docs/getting-started/mocks`;
|
|
|
68
69
|
});
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
|
-
if (
|
|
72
|
-
|
|
72
|
+
if (!(0, import_isCommonAssetRequest.isCommonAssetRequest)(request)) {
|
|
73
|
+
applyStrategy(strategy);
|
|
73
74
|
}
|
|
74
|
-
applyStrategy(strategy);
|
|
75
75
|
}
|
|
76
76
|
//# sourceMappingURL=onUnhandledRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/request/onUnhandledRequest.ts"],"sourcesContent":["import { toPublicUrl } from './toPublicUrl'\nimport { InternalError, devUtils } from '../internal/devUtils'\n\nexport interface UnhandledRequestPrint {\n warning(): void\n error(): void\n}\n\nexport type UnhandledRequestCallback = (\n request: Request,\n print: UnhandledRequestPrint,\n) => void\n\nexport type UnhandledRequestStrategy =\n | 'bypass'\n | 'warn'\n | 'error'\n | UnhandledRequestCallback\n\nexport async function onUnhandledRequest(\n request: Request,\n strategy: UnhandledRequestStrategy = 'warn',\n): Promise<void> {\n const url = new URL(request.url)\n const publicUrl = toPublicUrl(url) + url.search\n\n const requestBody =\n request.method === 'HEAD' || request.method === 'GET'\n ? null\n : await request.clone().text()\n const messageDetails = `\\n\\n \\u2022 ${request.method} ${publicUrl}\\n\\n${requestBody ? ` \\u2022 Request body: ${requestBody}\\n\\n` : ''}`\n const unhandledRequestMessage = `intercepted a request without a matching request handler:${messageDetails}If you still wish to intercept this unhandled request, please create a request handler for it.\\nRead more: https://mswjs.io/docs/getting-started/mocks`\n\n function applyStrategy(strategy: UnhandledRequestStrategy) {\n switch (strategy) {\n case 'error': {\n // Print a developer-friendly error.\n devUtils.error('Error: %s', unhandledRequestMessage)\n\n // Throw an exception to halt request processing and not perform the original request.\n throw new InternalError(\n devUtils.formatMessage(\n 'Cannot bypass a request when using the \"error\" strategy for the \"onUnhandledRequest\" option.',\n ),\n )\n }\n\n case 'warn': {\n devUtils.warn('Warning: %s', unhandledRequestMessage)\n break\n }\n\n case 'bypass':\n break\n\n default:\n throw new InternalError(\n devUtils.formatMessage(\n 'Failed to react to an unhandled request: unknown strategy \"%s\". Please provide one of the supported strategies (\"bypass\", \"warn\", \"error\") or a custom callback function as the value of the \"onUnhandledRequest\" option.',\n strategy,\n ),\n )\n }\n }\n\n if (typeof strategy === 'function') {\n strategy(request, {\n warning: applyStrategy.bind(null, 'warn'),\n error: applyStrategy.bind(null, 'error'),\n })\n return\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/request/onUnhandledRequest.ts"],"sourcesContent":["import { toPublicUrl } from './toPublicUrl'\nimport { InternalError, devUtils } from '../internal/devUtils'\nimport { isCommonAssetRequest } from '../../isCommonAssetRequest'\n\nexport interface UnhandledRequestPrint {\n warning(): void\n error(): void\n}\n\nexport type UnhandledRequestCallback = (\n request: Request,\n print: UnhandledRequestPrint,\n) => void\n\nexport type UnhandledRequestStrategy =\n | 'bypass'\n | 'warn'\n | 'error'\n | UnhandledRequestCallback\n\nexport async function onUnhandledRequest(\n request: Request,\n strategy: UnhandledRequestStrategy = 'warn',\n): Promise<void> {\n const url = new URL(request.url)\n const publicUrl = toPublicUrl(url) + url.search\n\n const requestBody =\n request.method === 'HEAD' || request.method === 'GET'\n ? null\n : await request.clone().text()\n const messageDetails = `\\n\\n \\u2022 ${request.method} ${publicUrl}\\n\\n${requestBody ? ` \\u2022 Request body: ${requestBody}\\n\\n` : ''}`\n const unhandledRequestMessage = `intercepted a request without a matching request handler:${messageDetails}If you still wish to intercept this unhandled request, please create a request handler for it.\\nRead more: https://mswjs.io/docs/getting-started/mocks`\n\n function applyStrategy(strategy: UnhandledRequestStrategy) {\n switch (strategy) {\n case 'error': {\n // Print a developer-friendly error.\n devUtils.error('Error: %s', unhandledRequestMessage)\n\n // Throw an exception to halt request processing and not perform the original request.\n throw new InternalError(\n devUtils.formatMessage(\n 'Cannot bypass a request when using the \"error\" strategy for the \"onUnhandledRequest\" option.',\n ),\n )\n }\n\n case 'warn': {\n devUtils.warn('Warning: %s', unhandledRequestMessage)\n break\n }\n\n case 'bypass':\n break\n\n default:\n throw new InternalError(\n devUtils.formatMessage(\n 'Failed to react to an unhandled request: unknown strategy \"%s\". Please provide one of the supported strategies (\"bypass\", \"warn\", \"error\") or a custom callback function as the value of the \"onUnhandledRequest\" option.',\n strategy,\n ),\n )\n }\n }\n\n if (typeof strategy === 'function') {\n strategy(request, {\n warning: applyStrategy.bind(null, 'warn'),\n error: applyStrategy.bind(null, 'error'),\n })\n return\n }\n\n // Ignore common static asset requests when using a built-in strategy.\n // There's a slight overhead here because this utility will create a request URL\n // instance again despite us having done so previously in this function.\n if (!isCommonAssetRequest(request)) {\n applyStrategy(strategy)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA4B;AAC5B,sBAAwC;AACxC,kCAAqC;AAkBrC,eAAsB,mBACpB,SACA,WAAqC,QACtB;AACf,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAC/B,QAAM,gBAAY,gCAAY,GAAG,IAAI,IAAI;AAEzC,QAAM,cACJ,QAAQ,WAAW,UAAU,QAAQ,WAAW,QAC5C,OACA,MAAM,QAAQ,MAAM,EAAE,KAAK;AACjC,QAAM,iBAAiB;AAAA;AAAA,WAAgB,QAAQ,MAAM,IAAI,SAAS;AAAA;AAAA,EAAO,cAAc,0BAA0B,WAAW;AAAA;AAAA,IAAS,EAAE;AACvI,QAAM,0BAA0B,4DAA4D,cAAc;AAAA;AAE1G,WAAS,cAAcA,WAAoC;AACzD,YAAQA,WAAU;AAAA,MAChB,KAAK,SAAS;AAEZ,iCAAS,MAAM,aAAa,uBAAuB;AAGnD,cAAM,IAAI;AAAA,UACR,yBAAS;AAAA,YACP;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,MAEA,KAAK,QAAQ;AACX,iCAAS,KAAK,eAAe,uBAAuB;AACpD;AAAA,MACF;AAAA,MAEA,KAAK;AACH;AAAA,MAEF;AACE,cAAM,IAAI;AAAA,UACR,yBAAS;AAAA,YACP;AAAA,YACAA;AAAA,UACF;AAAA,QACF;AAAA,IACJ;AAAA,EACF;AAEA,MAAI,OAAO,aAAa,YAAY;AAClC,aAAS,SAAS;AAAA,MAChB,SAAS,cAAc,KAAK,MAAM,MAAM;AAAA,MACxC,OAAO,cAAc,KAAK,MAAM,OAAO;AAAA,IACzC,CAAC;AACD;AAAA,EACF;AAKA,MAAI,KAAC,kDAAqB,OAAO,GAAG;AAClC,kBAAc,QAAQ;AAAA,EACxB;AACF;","names":["strategy"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { toPublicUrl } from './toPublicUrl.mjs';
|
|
2
2
|
import { InternalError, devUtils } from '../internal/devUtils.mjs';
|
|
3
|
+
import { isCommonAssetRequest } from '../../isCommonAssetRequest.mjs';
|
|
3
4
|
async function onUnhandledRequest(request, strategy = "warn") {
|
|
4
5
|
const url = new URL(request.url);
|
|
5
6
|
const publicUrl = toPublicUrl(url) + url.search;
|
|
@@ -45,10 +46,9 @@ Read more: https://mswjs.io/docs/getting-started/mocks`;
|
|
|
45
46
|
});
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
|
-
if (
|
|
49
|
-
|
|
49
|
+
if (!isCommonAssetRequest(request)) {
|
|
50
|
+
applyStrategy(strategy);
|
|
50
51
|
}
|
|
51
|
-
applyStrategy(strategy);
|
|
52
52
|
}
|
|
53
53
|
export {
|
|
54
54
|
onUnhandledRequest
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/request/onUnhandledRequest.ts"],"sourcesContent":["import { toPublicUrl } from './toPublicUrl'\nimport { InternalError, devUtils } from '../internal/devUtils'\n\nexport interface UnhandledRequestPrint {\n warning(): void\n error(): void\n}\n\nexport type UnhandledRequestCallback = (\n request: Request,\n print: UnhandledRequestPrint,\n) => void\n\nexport type UnhandledRequestStrategy =\n | 'bypass'\n | 'warn'\n | 'error'\n | UnhandledRequestCallback\n\nexport async function onUnhandledRequest(\n request: Request,\n strategy: UnhandledRequestStrategy = 'warn',\n): Promise<void> {\n const url = new URL(request.url)\n const publicUrl = toPublicUrl(url) + url.search\n\n const requestBody =\n request.method === 'HEAD' || request.method === 'GET'\n ? null\n : await request.clone().text()\n const messageDetails = `\\n\\n \\u2022 ${request.method} ${publicUrl}\\n\\n${requestBody ? ` \\u2022 Request body: ${requestBody}\\n\\n` : ''}`\n const unhandledRequestMessage = `intercepted a request without a matching request handler:${messageDetails}If you still wish to intercept this unhandled request, please create a request handler for it.\\nRead more: https://mswjs.io/docs/getting-started/mocks`\n\n function applyStrategy(strategy: UnhandledRequestStrategy) {\n switch (strategy) {\n case 'error': {\n // Print a developer-friendly error.\n devUtils.error('Error: %s', unhandledRequestMessage)\n\n // Throw an exception to halt request processing and not perform the original request.\n throw new InternalError(\n devUtils.formatMessage(\n 'Cannot bypass a request when using the \"error\" strategy for the \"onUnhandledRequest\" option.',\n ),\n )\n }\n\n case 'warn': {\n devUtils.warn('Warning: %s', unhandledRequestMessage)\n break\n }\n\n case 'bypass':\n break\n\n default:\n throw new InternalError(\n devUtils.formatMessage(\n 'Failed to react to an unhandled request: unknown strategy \"%s\". Please provide one of the supported strategies (\"bypass\", \"warn\", \"error\") or a custom callback function as the value of the \"onUnhandledRequest\" option.',\n strategy,\n ),\n )\n }\n }\n\n if (typeof strategy === 'function') {\n strategy(request, {\n warning: applyStrategy.bind(null, 'warn'),\n error: applyStrategy.bind(null, 'error'),\n })\n return\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/request/onUnhandledRequest.ts"],"sourcesContent":["import { toPublicUrl } from './toPublicUrl'\nimport { InternalError, devUtils } from '../internal/devUtils'\nimport { isCommonAssetRequest } from '../../isCommonAssetRequest'\n\nexport interface UnhandledRequestPrint {\n warning(): void\n error(): void\n}\n\nexport type UnhandledRequestCallback = (\n request: Request,\n print: UnhandledRequestPrint,\n) => void\n\nexport type UnhandledRequestStrategy =\n | 'bypass'\n | 'warn'\n | 'error'\n | UnhandledRequestCallback\n\nexport async function onUnhandledRequest(\n request: Request,\n strategy: UnhandledRequestStrategy = 'warn',\n): Promise<void> {\n const url = new URL(request.url)\n const publicUrl = toPublicUrl(url) + url.search\n\n const requestBody =\n request.method === 'HEAD' || request.method === 'GET'\n ? null\n : await request.clone().text()\n const messageDetails = `\\n\\n \\u2022 ${request.method} ${publicUrl}\\n\\n${requestBody ? ` \\u2022 Request body: ${requestBody}\\n\\n` : ''}`\n const unhandledRequestMessage = `intercepted a request without a matching request handler:${messageDetails}If you still wish to intercept this unhandled request, please create a request handler for it.\\nRead more: https://mswjs.io/docs/getting-started/mocks`\n\n function applyStrategy(strategy: UnhandledRequestStrategy) {\n switch (strategy) {\n case 'error': {\n // Print a developer-friendly error.\n devUtils.error('Error: %s', unhandledRequestMessage)\n\n // Throw an exception to halt request processing and not perform the original request.\n throw new InternalError(\n devUtils.formatMessage(\n 'Cannot bypass a request when using the \"error\" strategy for the \"onUnhandledRequest\" option.',\n ),\n )\n }\n\n case 'warn': {\n devUtils.warn('Warning: %s', unhandledRequestMessage)\n break\n }\n\n case 'bypass':\n break\n\n default:\n throw new InternalError(\n devUtils.formatMessage(\n 'Failed to react to an unhandled request: unknown strategy \"%s\". Please provide one of the supported strategies (\"bypass\", \"warn\", \"error\") or a custom callback function as the value of the \"onUnhandledRequest\" option.',\n strategy,\n ),\n )\n }\n }\n\n if (typeof strategy === 'function') {\n strategy(request, {\n warning: applyStrategy.bind(null, 'warn'),\n error: applyStrategy.bind(null, 'error'),\n })\n return\n }\n\n // Ignore common static asset requests when using a built-in strategy.\n // There's a slight overhead here because this utility will create a request URL\n // instance again despite us having done so previously in this function.\n if (!isCommonAssetRequest(request)) {\n applyStrategy(strategy)\n }\n}\n"],"mappings":"AAAA,SAAS,mBAAmB;AAC5B,SAAS,eAAe,gBAAgB;AACxC,SAAS,4BAA4B;AAkBrC,eAAsB,mBACpB,SACA,WAAqC,QACtB;AACf,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAC/B,QAAM,YAAY,YAAY,GAAG,IAAI,IAAI;AAEzC,QAAM,cACJ,QAAQ,WAAW,UAAU,QAAQ,WAAW,QAC5C,OACA,MAAM,QAAQ,MAAM,EAAE,KAAK;AACjC,QAAM,iBAAiB;AAAA;AAAA,WAAgB,QAAQ,MAAM,IAAI,SAAS;AAAA;AAAA,EAAO,cAAc,0BAA0B,WAAW;AAAA;AAAA,IAAS,EAAE;AACvI,QAAM,0BAA0B,4DAA4D,cAAc;AAAA;AAE1G,WAAS,cAAcA,WAAoC;AACzD,YAAQA,WAAU;AAAA,MAChB,KAAK,SAAS;AAEZ,iBAAS,MAAM,aAAa,uBAAuB;AAGnD,cAAM,IAAI;AAAA,UACR,SAAS;AAAA,YACP;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,MAEA,KAAK,QAAQ;AACX,iBAAS,KAAK,eAAe,uBAAuB;AACpD;AAAA,MACF;AAAA,MAEA,KAAK;AACH;AAAA,MAEF;AACE,cAAM,IAAI;AAAA,UACR,SAAS;AAAA,YACP;AAAA,YACAA;AAAA,UACF;AAAA,QACF;AAAA,IACJ;AAAA,EACF;AAEA,MAAI,OAAO,aAAa,YAAY;AAClC,aAAS,SAAS;AAAA,MAChB,SAAS,cAAc,KAAK,MAAM,MAAM;AAAA,MACxC,OAAO,cAAc,KAAK,MAAM,OAAO;AAAA,IACzC,CAAC;AACD;AAAA,EACF;AAKA,MAAI,CAAC,qBAAqB,OAAO,GAAG;AAClC,kBAAc,QAAQ;AAAA,EACxB;AACF;","names":["strategy"]}
|
|
@@ -29,7 +29,7 @@ function getAbsoluteUrl(path, baseUrl) {
|
|
|
29
29
|
if (path.startsWith("*")) {
|
|
30
30
|
return path;
|
|
31
31
|
}
|
|
32
|
-
const origin = baseUrl || typeof
|
|
32
|
+
const origin = baseUrl || typeof location !== "undefined" && location.href;
|
|
33
33
|
return origin ? (
|
|
34
34
|
// Encode and decode the path to preserve escaped characters.
|
|
35
35
|
decodeURI(new URL(encodeURI(path), origin).href)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/url/getAbsoluteUrl.ts"],"sourcesContent":["import { isAbsoluteUrl } from './isAbsoluteUrl'\n\n/**\n * Returns an absolute URL based on the given path.\n */\nexport function getAbsoluteUrl(path: string, baseUrl?: string): string {\n // already absolute URL\n if (isAbsoluteUrl(path)) {\n return path\n }\n\n // Ignore path with pattern start with *\n if (path.startsWith('*')) {\n return path\n }\n\n // Resolve a relative request URL against a given custom \"baseUrl\"\n // or the document baseURI (in the case of browser/browser-like environments).\n const origin
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/url/getAbsoluteUrl.ts"],"sourcesContent":["import { isAbsoluteUrl } from './isAbsoluteUrl'\n\n/**\n * Returns an absolute URL based on the given path.\n */\nexport function getAbsoluteUrl(path: string, baseUrl?: string): string {\n // already absolute URL\n if (isAbsoluteUrl(path)) {\n return path\n }\n\n // Ignore path with pattern start with *\n if (path.startsWith('*')) {\n return path\n }\n\n // Resolve a relative request URL against a given custom \"baseUrl\"\n // or the document baseURI (in the case of browser/browser-like environments).\n const origin = baseUrl || (typeof location !== 'undefined' && location.href)\n\n return origin\n ? // Encode and decode the path to preserve escaped characters.\n decodeURI(new URL(encodeURI(path), origin).href)\n : path\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAA8B;AAKvB,SAAS,eAAe,MAAc,SAA0B;AAErE,UAAI,oCAAc,IAAI,GAAG;AACvB,WAAO;AAAA,EACT;AAGA,MAAI,KAAK,WAAW,GAAG,GAAG;AACxB,WAAO;AAAA,EACT;AAIA,QAAM,SAAS,WAAY,OAAO,aAAa,eAAe,SAAS;AAEvE,SAAO;AAAA;AAAA,IAEH,UAAU,IAAI,IAAI,UAAU,IAAI,GAAG,MAAM,EAAE,IAAI;AAAA,MAC/C;AACN;","names":[]}
|
|
@@ -6,7 +6,7 @@ function getAbsoluteUrl(path, baseUrl) {
|
|
|
6
6
|
if (path.startsWith("*")) {
|
|
7
7
|
return path;
|
|
8
8
|
}
|
|
9
|
-
const origin = baseUrl || typeof
|
|
9
|
+
const origin = baseUrl || typeof location !== "undefined" && location.href;
|
|
10
10
|
return origin ? (
|
|
11
11
|
// Encode and decode the path to preserve escaped characters.
|
|
12
12
|
decodeURI(new URL(encodeURI(path), origin).href)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/url/getAbsoluteUrl.ts"],"sourcesContent":["import { isAbsoluteUrl } from './isAbsoluteUrl'\n\n/**\n * Returns an absolute URL based on the given path.\n */\nexport function getAbsoluteUrl(path: string, baseUrl?: string): string {\n // already absolute URL\n if (isAbsoluteUrl(path)) {\n return path\n }\n\n // Ignore path with pattern start with *\n if (path.startsWith('*')) {\n return path\n }\n\n // Resolve a relative request URL against a given custom \"baseUrl\"\n // or the document baseURI (in the case of browser/browser-like environments).\n const origin
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/url/getAbsoluteUrl.ts"],"sourcesContent":["import { isAbsoluteUrl } from './isAbsoluteUrl'\n\n/**\n * Returns an absolute URL based on the given path.\n */\nexport function getAbsoluteUrl(path: string, baseUrl?: string): string {\n // already absolute URL\n if (isAbsoluteUrl(path)) {\n return path\n }\n\n // Ignore path with pattern start with *\n if (path.startsWith('*')) {\n return path\n }\n\n // Resolve a relative request URL against a given custom \"baseUrl\"\n // or the document baseURI (in the case of browser/browser-like environments).\n const origin = baseUrl || (typeof location !== 'undefined' && location.href)\n\n return origin\n ? // Encode and decode the path to preserve escaped characters.\n decodeURI(new URL(encodeURI(path), origin).href)\n : path\n}\n"],"mappings":"AAAA,SAAS,qBAAqB;AAKvB,SAAS,eAAe,MAAc,SAA0B;AAErE,MAAI,cAAc,IAAI,GAAG;AACvB,WAAO;AAAA,EACT;AAGA,MAAI,KAAK,WAAW,GAAG,GAAG;AACxB,WAAO;AAAA,EACT;AAIA,QAAM,SAAS,WAAY,OAAO,aAAa,eAAe,SAAS;AAEvE,SAAO;AAAA;AAAA,IAEH,UAAU,IAAI,IAAI,UAAU,IAAI,GAAG,MAAM,EAAE,IAAI;AAAA,MAC/C;AACN;","names":[]}
|
package/lib/iife/index.js
CHANGED
|
@@ -13133,6 +13133,7 @@ ${operationTypes.join("\n")}
|
|
|
13133
13133
|
graphql: () => graphql2,
|
|
13134
13134
|
handleRequest: () => handleRequest,
|
|
13135
13135
|
http: () => http,
|
|
13136
|
+
isCommonAssetRequest: () => isCommonAssetRequest,
|
|
13136
13137
|
matchRequestUrl: () => matchRequestUrl,
|
|
13137
13138
|
passthrough: () => passthrough,
|
|
13138
13139
|
setupWorker: () => setupWorker,
|
|
@@ -14829,7 +14830,7 @@ ${operationTypes.join("\n")}
|
|
|
14829
14830
|
if (path.startsWith("*")) {
|
|
14830
14831
|
return path;
|
|
14831
14832
|
}
|
|
14832
|
-
const origin = baseUrl || typeof
|
|
14833
|
+
const origin = baseUrl || typeof location !== "undefined" && location.href;
|
|
14833
14834
|
return origin ? (
|
|
14834
14835
|
// Encode and decode the path to preserve escaped characters.
|
|
14835
14836
|
decodeURI(new URL(encodeURI(path), origin).href)
|
|
@@ -28497,6 +28498,26 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
28497
28498
|
return null;
|
|
28498
28499
|
};
|
|
28499
28500
|
|
|
28501
|
+
// src/core/isCommonAssetRequest.ts
|
|
28502
|
+
function isCommonAssetRequest(request) {
|
|
28503
|
+
const url = new URL(request.url);
|
|
28504
|
+
if (url.protocol === "file:") {
|
|
28505
|
+
return true;
|
|
28506
|
+
}
|
|
28507
|
+
if (/(fonts\.googleapis\.com)/.test(url.hostname)) {
|
|
28508
|
+
return true;
|
|
28509
|
+
}
|
|
28510
|
+
if (/node_modules/.test(url.pathname)) {
|
|
28511
|
+
return true;
|
|
28512
|
+
}
|
|
28513
|
+
if (url.pathname.includes("@vite")) {
|
|
28514
|
+
return true;
|
|
28515
|
+
}
|
|
28516
|
+
return /\.(s?css|less|m?jsx?|m?tsx?|html|ttf|otf|woff|woff2|eot|gif|jpe?g|png|avif|webp|svg|mp4|webm|ogg|mov|mp3|wav|ogg|flac|aac|pdf|txt|csv|json|xml|md|zip|tar|gz|rar|7z)$/i.test(
|
|
28517
|
+
url.pathname
|
|
28518
|
+
);
|
|
28519
|
+
}
|
|
28520
|
+
|
|
28500
28521
|
// src/core/utils/request/onUnhandledRequest.ts
|
|
28501
28522
|
async function onUnhandledRequest(request, strategy = "warn") {
|
|
28502
28523
|
const url = new URL(request.url);
|
|
@@ -28543,10 +28564,9 @@ Read more: https://mswjs.io/docs/getting-started/mocks`;
|
|
|
28543
28564
|
});
|
|
28544
28565
|
return;
|
|
28545
28566
|
}
|
|
28546
|
-
if (
|
|
28547
|
-
|
|
28567
|
+
if (!isCommonAssetRequest(request)) {
|
|
28568
|
+
applyStrategy(strategy);
|
|
28548
28569
|
}
|
|
28549
|
-
applyStrategy(strategy);
|
|
28550
28570
|
}
|
|
28551
28571
|
|
|
28552
28572
|
// src/core/utils/HttpResponse/decorators.ts
|