From 9640b184adddde79d67f9aafd83cd4af9133e581 Mon Sep 17 00:00:00 2001 From: kien-ngo <26052673+kien-ngo@users.noreply.github.com> Date: Mon, 5 Aug 2024 16:59:17 +0000 Subject: [PATCH] Dashboard: Fix [Open IPFS folder] link (#3935) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem solved Short description of the bug fixed or feature added --- ## PR-Codex overview The focus of this PR is to refactor the logic for getting the folder path from an IPFS hash URL in the `dropzone.tsx` component. ### Detailed summary - Refactored logic to extract folder path from IPFS hash URL - Updated return statement to use the extracted folder path for the IPFS URL > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- apps/dashboard/src/components/ipfs-upload/dropzone.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/dashboard/src/components/ipfs-upload/dropzone.tsx b/apps/dashboard/src/components/ipfs-upload/dropzone.tsx index f3a04b5b130..ff642dde7b8 100644 --- a/apps/dashboard/src/components/ipfs-upload/dropzone.tsx +++ b/apps/dashboard/src/components/ipfs-upload/dropzone.tsx @@ -192,8 +192,9 @@ const FileUpload: React.FC = ({ files, updateFiles }) => { return replaceIpfsUrl(ipfsHashes[0]); } // get the folder - // return replaceIpfsUrl(ipfsHashes[0].split("/").slice(0, -1).join("/")); - return `https://ipfs.io/ipfs/${ipfsHashes[0].split("ipfs://")[1]}`; + const uri = ipfsHashes[0].split("ipfs://")[1]; + const folderPath = uri.split("/")[0]; // "Qma.../image.png" -> "Qma..." + return `https://ipfs.io/ipfs/${folderPath}`; }, [ipfsHashes]); const filesToShow = useMemo(() => {