Skip to content

Commit

Permalink
Dashboard: Fix [Open IPFS folder] link (#3935)
Browse files Browse the repository at this point in the history
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## 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}`

<!-- end pr-codex -->
  • Loading branch information
kien-ngo committed Aug 5, 2024
1 parent a2e1382 commit 9640b18
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions apps/dashboard/src/components/ipfs-upload/dropzone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ const FileUpload: React.FC<FileUploadProps> = ({ 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(() => {
Expand Down

0 comments on commit 9640b18

Please sign in to comment.