Skip to content

Commit 50b8475

Browse files
committed
fix: return URL with trailing slash
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]>
1 parent 61813f0 commit 50b8475

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/url-utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const gatewayHttpUrl = (cid, gatewayProvider = 'ipfs') => {
1818
return origin
1919
}
2020

21-
return `${origin}/ipfs/${cid}`
21+
return `${origin}/ipfs/${cid}/`
2222
}
2323

2424
const linkCid = (cid, gatewayProvider) => `🔗 ${chalk.green(

test/url-utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ const proxyquire = require('proxyquire').noCallThru()
33
const { gatewayHttpUrl } = require('../src/url-utils')
44

55
test('get http gateway url for a cid', t => {
6-
const expected = 'https://ipfs.io/ipfs/fakecid'
6+
const expected = 'https://ipfs.io/ipfs/fakecid/'
77
const actual = gatewayHttpUrl('fakecid')
88
t.is(actual, expected)
99
})
1010

1111
test('get http gateway url for a cid on infura', t => {
12-
const expected = 'https://ipfs.infura.io/ipfs/fakecid'
12+
const expected = 'https://ipfs.infura.io/ipfs/fakecid/'
1313
const actual = gatewayHttpUrl('fakecid', 'infura')
1414
t.is(actual, expected)
1515
})
1616

1717
test('get http gateway url for a cid on pinata', t => {
18-
const expected = 'https://gateway.pinata.cloud/ipfs/fakecid'
18+
const expected = 'https://gateway.pinata.cloud/ipfs/fakecid/'
1919
const actual = gatewayHttpUrl('fakecid', 'pinata')
2020
t.is(actual, expected)
2121
})

0 commit comments

Comments
 (0)