diff --git a/dapp/src/components/page/proposal/ProposalPage.tsx b/dapp/src/components/page/proposal/ProposalPage.tsx index 0a19651..b88d318 100644 --- a/dapp/src/components/page/proposal/ProposalPage.tsx +++ b/dapp/src/components/page/proposal/ProposalPage.tsx @@ -15,7 +15,6 @@ import { } from "@service/ProposalService"; import type { ProposalOutcome, - Proposal, ProposalView, ProposalViewStatus, VoteType, diff --git a/dapp/src/service/ProposalService.ts b/dapp/src/service/ProposalService.ts index 4c96a9d..023ca79 100644 --- a/dapp/src/service/ProposalService.ts +++ b/dapp/src/service/ProposalService.ts @@ -1,15 +1,22 @@ import axios from "axios"; -import { getOutcomeLinkFromIpfs, getProposalLinkFromIpfs } from "utils/utils"; +import { + getIpfsBasicLink, + getOutcomeLinkFromIpfs, + getProposalLinkFromIpfs, +} from "utils/utils"; async function fetchProposalFromIPFS(url: string) { try { const proposalUrl = getProposalLinkFromIpfs(url); const response = await axios.get(proposalUrl); let content = response.data; + + const basicUrl = getIpfsBasicLink(url); content = content.replace( /!\[([^\]]*)\]\(([^http][^)]+)\)/g, - `![$1](${url}$2)`, + `![$1](${basicUrl}$2)`, ); + return content; } catch (error) { console.error("Error fetching the IPFS file:", error); diff --git a/dapp/src/utils/utils.ts b/dapp/src/utils/utils.ts index a72931b..aa0bc28 100644 --- a/dapp/src/utils/utils.ts +++ b/dapp/src/utils/utils.ts @@ -64,6 +64,10 @@ export const modifySlashInXdr = (xdr: string) => { return xdr.replaceAll("/", "//"); }; +export const getIpfsBasicLink = (ipfsLink: string) => { + return `https://${ipfsLink}.ipfs.w3s.link/`; +}; + export const getProposalLinkFromIpfs = (ipfsLink: string) => { return `https://${ipfsLink}.ipfs.w3s.link/proposal.md`; };