Skip to content

Commit 0852dec

Browse files
committed
chore: don't warn for unmocked data: URLs
I noticed this in test logs: ``` [WebServer] [test-fixtures] NO FIXTURE PATTERN [WebServer] ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ [WebServer] URL does not match any known fixture pattern [WebServer] URL: data:application/octet-stream;base64,AGFzbQEAAAABugM3YAF/AGACf38AYAF/AX9gA39/fwBgAn98AGACf38Bf2ADf39/AX9gBH9/[...snip...] ````
1 parent eeeb6b6 commit 0852dec

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modules/runtime/server/cache.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,12 +710,17 @@ export default defineNitroPlugin(nitroApp => {
710710
const originalFetch = globalThis.fetch
711711
const original$fetch = globalThis.$fetch
712712

713-
// Override native fetch for esm.sh requests
713+
// Override native fetch for esm.sh requests and to inject test fixture responses
714714
globalThis.fetch = async (input: URL | RequestInfo, init?: RequestInit): Promise<Response> => {
715715
const urlStr =
716716
typeof input === 'string' ? input : input instanceof URL ? input.toString() : input.url
717717

718-
if (urlStr.startsWith('/') || urlStr.includes('woff') || urlStr.includes('fonts')) {
718+
if (
719+
urlStr.startsWith('/') ||
720+
urlStr.startsWith('data:') ||
721+
urlStr.includes('woff') ||
722+
urlStr.includes('fonts')
723+
) {
719724
return await originalFetch(input, init)
720725
}
721726

0 commit comments

Comments
 (0)