Skip to content

Commit

Permalink
fix: handle undefined or empty image source values (#1300)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThimoDEV committed Apr 22, 2024
1 parent 55c2717 commit 597c70b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/runtime/components/_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useImage } from '#imports'

export const baseImageProps = {
// input source
src: { type: String, required: true },
src: { type: String, default: undefined },

// modifiers
format: { type: String, default: undefined },
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ async function getMeta(ctx: ImageCTX, input: string, options?: ImageOptions) {
}

function resolveImage(ctx: ImageCTX, input: string, options: ImageOptions): ResolvedImage {
if (typeof input !== 'string' || input === '') {
if (input && typeof input !== 'string') {
throw new TypeError(`input must be a string (received ${typeof input}: ${JSON.stringify(input)})`)
}

if (input.startsWith('data:')) {
if (!input || input.startsWith('data:')) {
return {
url: input,
}
Expand Down

0 comments on commit 597c70b

Please sign in to comment.