simplify means of checking to see if unhandled paths should log a warning

This commit is contained in:
Jacob Overgaard
2023-02-01 10:14:10 +01:00
parent bdad73f230
commit fed52d3a3b

View File

@@ -1,16 +1,13 @@
import { MockedRequest, setupWorker } from 'msw';
import { handlers } from './browser-handlers';
import { umbracoPath } from '@umbraco-cms/utils';
const worker = setupWorker(...handlers);
export const onUnhandledRequest = (req: MockedRequest) => {
if (req.url.pathname.startsWith('/node_modules/')) return;
if (req.url.pathname.startsWith('/src/')) return;
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);
if (req.url.pathname.startsWith(umbracoPath(''))) {
console.warn('Found an unhandled %s request to %s', req.method, req.url.href);
}
};
export const startMockServiceWorker = () =>