From ec0efe8a06d0271ef0154f38fb9beabcd4b1bd89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Mon, 30 Sep 2024 17:57:36 +0900 Subject: [PATCH] fix(data-uri): only match ids starting with `data:` (#18241) --- packages/vite/src/node/plugins/dataUri.ts | 2 +- playground/data-uri/index.html | 4 ++++ playground/data-uri/vite.config.js | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 playground/data-uri/vite.config.js diff --git a/packages/vite/src/node/plugins/dataUri.ts b/packages/vite/src/node/plugins/dataUri.ts index c2a71a88ca14d1..9560700a5fd80e 100644 --- a/packages/vite/src/node/plugins/dataUri.ts +++ b/packages/vite/src/node/plugins/dataUri.ts @@ -22,7 +22,7 @@ export function dataURIPlugin(): Plugin { }, resolveId(id) { - if (!dataUriRE.test(id)) { + if (!id.trimStart().startsWith('data:')) { return } diff --git a/playground/data-uri/index.html b/playground/data-uri/index.html index 597c3a204f36c9..3794f74db4ea3e 100644 --- a/playground/data-uri/index.html +++ b/playground/data-uri/index.html @@ -1,5 +1,6 @@
+