feat: support URL obj for toGateway
This commit is contained in:
parent
5d3df2d150
commit
cc818a9f6b
|
|
@ -25,7 +25,7 @@ export const Avatar: React.FC<
|
|||
|
||||
const image = useMemo(() => {
|
||||
for (const image of images) {
|
||||
if (image) return toGateway((image as any)?.url || image)
|
||||
if (image) return toGateway(image)
|
||||
}
|
||||
}, [images])
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,13 @@ export type ToGatewayConfig = {
|
|||
forceFallback?: boolean
|
||||
}
|
||||
|
||||
export const toGateway = (url: string) => {
|
||||
const ipfsUrl = toIPFS(url)
|
||||
export const toGateway = (url: string | URL) => {
|
||||
let ipfsUrl
|
||||
if (typeof url === "string") {
|
||||
ipfsUrl = toIPFS(url)
|
||||
} else {
|
||||
ipfsUrl = toIPFS(url.toString())
|
||||
}
|
||||
|
||||
return ipfsUrl?.replaceAll(IPFS_PREFIX, IPFS_GATEWAY)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue