Skip to content

Commit

Permalink
Merge pull request #167 from Corantin/fix-extra-slash-when-fetching-ipfs
Browse files Browse the repository at this point in the history
Trim slash of gateway if already end with it
  • Loading branch information
kamikazebr authored Aug 26, 2023
2 parents 6618d9b + 1b59103 commit 43ce94e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16
- name: Cache yarn modules
uses: actions/cache@v2
with:
path: "**/node_modules"
key: yarn-${{ hashFiles('yarn.lock') }}
- name: Install dependencies
run: yarn install --frozen-lockfile
run: yarn install
- name: Lint
run: yarn lint
- name: Build Celeste Dashboard
Expand Down
9 changes: 5 additions & 4 deletions src/hooks/useDisputes.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,13 @@ async function processRawDisputeData(dispute) {
// Note that in this case, we expect the agreement's location to be relative to the
// metadata URI. For example, if the metadataUri is `<cid>/metadata.json`, the agreement's
// location would be `<cid>/<agreement>`
let ipfsEndpoint = defaultIpfsEndpoint()
if (ipfsEndpoint.endsWith('/')) {
ipfsEndpoint = ipfsEndpoint.slice(0, -1)
}
const agreementUrl =
ipfsPath && agreementText
? resolvePathname(
agreementText,
`${defaultIpfsEndpoint()}/${ipfsPath}`
)
? resolvePathname(agreementText, `${ipfsEndpoint}/${ipfsPath}`)
: ''

const {
Expand Down
6 changes: 5 additions & 1 deletion src/lib/ipfs-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ const TEST_IPFS_REGEX = /(Qm[a-zA-Z0-9]{44})/
const REQUEST_TIMEOUT = 60000

export const ipfsGet = async cid => {
const endpoint = `${getIpfsGateway()}/${cid}`
let ipfsGateway = getIpfsGateway()
if (ipfsGateway.endsWith('/')) {
ipfsGateway = ipfsGateway.slice(0, -1)
}
const endpoint = `${ipfsGateway}/${cid}`
try {
const result = await fetch(endpoint, { timeout: REQUEST_TIMEOUT })
const data = await result.text()
Expand Down

1 comment on commit 43ce94e

@vercel
Copy link

@vercel vercel bot commented on 43ce94e Aug 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.