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>
This commit is contained in:
asivery 2024-10-29 09:10:47 +01:00 committed by GitHub
parent 2c10f9a452
commit a0336bd519
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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