Skip to content

Commit

Permalink
move isRemovePath check
Browse files Browse the repository at this point in the history
  • Loading branch information
DerTimonius committed Oct 12, 2024
1 parent 2253d35 commit e60d305
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/astro/src/assets/internal.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions packages/astro/src/assets/utils/imageKind.ts
Original file line number Diff line number Diff line change
@@ -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']) {
Expand Down

0 comments on commit e60d305

Please sign in to comment.