simplify means of checking to see if unhandled paths should log a warning
This commit is contained in:
@@ -1,16 +1,13 @@
|
|||||||
import { MockedRequest, setupWorker } from 'msw';
|
import { MockedRequest, setupWorker } from 'msw';
|
||||||
|
|
||||||
import { handlers } from './browser-handlers';
|
import { handlers } from './browser-handlers';
|
||||||
|
import { umbracoPath } from '@umbraco-cms/utils';
|
||||||
|
|
||||||
const worker = setupWorker(...handlers);
|
const worker = setupWorker(...handlers);
|
||||||
|
|
||||||
export const onUnhandledRequest = (req: MockedRequest) => {
|
export const onUnhandledRequest = (req: MockedRequest) => {
|
||||||
if (req.url.pathname.startsWith('/node_modules/')) return;
|
if (req.url.pathname.startsWith(umbracoPath(''))) {
|
||||||
if (req.url.pathname.startsWith('/src/')) return;
|
console.warn('Found an unhandled %s request to %s', req.method, req.url.href);
|
||||||
if (req.url.pathname.startsWith('/icons/')) return;
|
}
|
||||||
if (req.destination === 'image') return;
|
|
||||||
|
|
||||||
console.warn('Found an unhandled %s request to %s', req.method, req.url.href);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const startMockServiceWorker = () =>
|
export const startMockServiceWorker = () =>
|
||||||
|
|||||||
Reference in New Issue
Block a user