Skip to content

Commit

Permalink
fix: return URL with trailing slash
Browse files Browse the repository at this point in the history
Removes the need for internal redirect done by gateway
and closes #86 on gateways that override that behavior.

License: MIT
Signed-off-by: Marcin Rataj <[email protected]>
  • Loading branch information
lidel committed Sep 6, 2019
1 parent 61813f0 commit 50b8475
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/url-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const gatewayHttpUrl = (cid, gatewayProvider = 'ipfs') => {
return origin
}

return `${origin}/ipfs/${cid}`
return `${origin}/ipfs/${cid}/`
}

const linkCid = (cid, gatewayProvider) => `🔗 ${chalk.green(
Expand Down
6 changes: 3 additions & 3 deletions test/url-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ const proxyquire = require('proxyquire').noCallThru()
const { gatewayHttpUrl } = require('../src/url-utils')

test('get http gateway url for a cid', t => {
const expected = 'https://ipfs.io/ipfs/fakecid'
const expected = 'https://ipfs.io/ipfs/fakecid/'
const actual = gatewayHttpUrl('fakecid')
t.is(actual, expected)
})

test('get http gateway url for a cid on infura', t => {
const expected = 'https://ipfs.infura.io/ipfs/fakecid'
const expected = 'https://ipfs.infura.io/ipfs/fakecid/'
const actual = gatewayHttpUrl('fakecid', 'infura')
t.is(actual, expected)
})

test('get http gateway url for a cid on pinata', t => {
const expected = 'https://gateway.pinata.cloud/ipfs/fakecid'
const expected = 'https://gateway.pinata.cloud/ipfs/fakecid/'
const actual = gatewayHttpUrl('fakecid', 'pinata')
t.is(actual, expected)
})
Expand Down

0 comments on commit 50b8475

Please sign in to comment.