Skip to content

Commit a0336bd

Browse files
asiverypatak-catbluwysapphi-red
authored
fix: consider URLs with any protocol to be external (#17369)
Co-authored-by: patak-dev <matias.capeletto@gmail.com> Co-authored-by: bluwy <bjornlu.dev@gmail.com> Co-authored-by: sapphi-red <49056869+sapphi-red@users.noreply.github.com>
1 parent 2c10f9a commit a0336bd

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

packages/vite/src/node/plugins/importAnalysis.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,10 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
509509
// If resolvable, let's resolve it
510510
if (specifier !== undefined) {
511511
// skip external / data uri
512-
if (isExternalUrl(specifier) || isDataUrl(specifier)) {
512+
if (
513+
(isExternalUrl(specifier) && !specifier.startsWith('file://')) ||
514+
isDataUrl(specifier)
515+
) {
513516
return
514517
}
515518
// skip ssr externals and builtins

packages/vite/src/node/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ export function isSameFileUri(file1: string, file2: string): boolean {
262262
)
263263
}
264264

265-
export const externalRE = /^(https?:)?\/\//
265+
export const externalRE = /^([a-z]+:)?\/\//
266266
export const isExternalUrl = (url: string): boolean => externalRE.test(url)
267267

268268
export const dataUrlRE = /^\s*data:/i

0 commit comments

Comments
 (0)