From e60d3052f815ef9e53d080cabfd66f420d564753 Mon Sep 17 00:00:00 2001 From: Timon Jurschitsch Date: Sat, 12 Oct 2024 16:46:03 +0200 Subject: [PATCH] move isRemovePath check --- packages/astro/src/assets/internal.ts | 7 ++++++- packages/astro/src/assets/utils/imageKind.ts | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/astro/src/assets/internal.ts b/packages/astro/src/assets/internal.ts index 4cc85799c154..58cd41f43235 100644 --- a/packages/astro/src/assets/internal.ts +++ b/packages/astro/src/assets/internal.ts @@ -1,3 +1,4 @@ +import { isRemotePath } from '@astrojs/internal-helpers/path'; import type { AstroConfig } from '../@types/astro.js'; import { AstroError, AstroErrorData } from '../core/errors/index.js'; import { DEFAULT_HASH_PROPS } from './consts.js'; @@ -65,7 +66,11 @@ export async function getImage( }; // Infer size for remote images if inferSize is true - if (options.inferSize && isRemoteImage(resolvedOptions.src)) { + if ( + options.inferSize && + isRemoteImage(resolvedOptions.src) && + isRemotePath(resolvedOptions.src) + ) { const result = await inferRemoteSize(resolvedOptions.src); // Directly probe the image URL resolvedOptions.width ??= result.width; resolvedOptions.height ??= result.height; diff --git a/packages/astro/src/assets/utils/imageKind.ts b/packages/astro/src/assets/utils/imageKind.ts index d8295ca5adc6..e3e1b3341a4b 100644 --- a/packages/astro/src/assets/utils/imageKind.ts +++ b/packages/astro/src/assets/utils/imageKind.ts @@ -1,12 +1,11 @@ import type { ImageMetadata, UnresolvedImageTransform } from '../types.js'; -import { isRemotePath } from '@astrojs/internal-helpers/path'; export function isESMImportedImage(src: ImageMetadata | string): src is ImageMetadata { return typeof src === 'object'; } export function isRemoteImage(src: ImageMetadata | string): src is string { - return typeof src === 'string' && isRemotePath(src); + return typeof src === 'string'; } export async function resolveSrc(src: UnresolvedImageTransform['src']) {