Skip to content

Commit

Permalink
fix: all urls should come pre-sanitized to 2d renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuripetusko committed Apr 22, 2024
1 parent dd15455 commit 661c169
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/rmrk-2d-renderer/src/lib/rmrk-2d-renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Container, Sprite, Stage, useApp } from '@pixi/react';
import { sanitizeIpfsUrl } from '@rmrk-team/ipfs-utils';
import DOMPurify from 'isomorphic-dompurify';
// import { Skeleton } from './ui/skeleton';
import { Loader2 } from 'lucide-react';
Expand Down Expand Up @@ -283,8 +282,7 @@ const useCreateResourceTexture = (
onLoad: (w: number, h: number) => void,
theme?: Record<string | number | symbol, unknown>,
) => {
const url = sanitizeIpfsUrl(src);
const [image] = (useImage as unknown as useImage)(url, 'anonymous');
const [image] = (useImage as unknown as useImage)(src, 'anonymous');

useEffect(() => {
if (image) {
Expand All @@ -297,7 +295,7 @@ const useCreateResourceTexture = (

useEffect(() => {
const downloadImage = async () => {
const response = await fetch(url);
const response = await fetch(src);
const contentType = response.headers.get('content-type');
const code = await response.text();

Expand Down Expand Up @@ -348,14 +346,14 @@ const useCreateResourceTexture = (
}
};

if (url && theme) {
if (src && theme) {
downloadImage();
}

if (image && !theme) {
setResourceTexture(Texture.from(image));
}
}, [url, image, theme]);
}, [src, image, theme]);

return resourceTexture;
};
Expand Down

0 comments on commit 661c169

Please sign in to comment.