Skip to content

Commit

Permalink
triple check image is at least valid url
Browse files Browse the repository at this point in the history
  • Loading branch information
xHomu committed Oct 21, 2024
1 parent 04087d8 commit a207af5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/components/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ export function Image({
width={width ?? searchParams.get("width") ?? undefined}
height={height ?? searchParams.get("height") ?? undefined}
alt={alt}
src={url ? `${url}?${searchParams.toString()}` : "/favicon.ico"}
src={
url && URL.canParse(url)
? `${url}?${searchParams.toString()}`
: "/favicon.ico"
}
/>
);

Expand Down Expand Up @@ -111,7 +115,11 @@ export function Image({
alt={alt}
sizes={srcSet ? `(min-width: 1200px) 728px, 100vw` : undefined}
srcSet={srcSet}
src={url ? `${url}?${searchParams.toString()}` : "/favicon.ico"}
src={
url && URL.canParse(url)
? `${url}?${searchParams.toString()}`
: "/favicon.ico"
}
/>
);
}

0 comments on commit a207af5

Please sign in to comment.