Skip to content

Commit

Permalink
fix: consider URLs with any protocol to be external (#17369)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
4 people authored Oct 29, 2024
1 parent 2c10f9a commit a0336bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/vite/src/node/plugins/importAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,10 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
// If resolvable, let's resolve it
if (specifier !== undefined) {
// skip external / data uri
if (isExternalUrl(specifier) || isDataUrl(specifier)) {
if (
(isExternalUrl(specifier) && !specifier.startsWith('file://')) ||
isDataUrl(specifier)
) {
return
}
// skip ssr externals and builtins
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export function isSameFileUri(file1: string, file2: string): boolean {
)
}

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

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

0 comments on commit a0336bd

Please sign in to comment.