feat: check image src

This commit is contained in:
DIYgod 2023-03-29 01:46:09 +01:00
parent 0f2abe9e44
commit 7a1fc5d3e8
No known key found for this signature in database
1 changed files with 6 additions and 1 deletions

View File

@ -1,7 +1,6 @@
import React from "react"
import { default as NextImage, ImageProps } from "next/image"
import { toGateway, toIPFS } from "~/lib/ipfs-parser"
import { cn } from "~/lib/utils"
export const Image: React.FC<
{
@ -20,6 +19,12 @@ export const Image: React.FC<
const autoSize = !width && !height && !fill
const noOptimization = className?.includes("no-optimization")
try {
new URL(src)
} catch (error) {
return null
}
return noOptimization ? (
// eslint-disable-next-line @next/next/no-img-element
<img