Skip to content

Commit 0b57b6c

Browse files
committed
fix bug with too many "/" after a ipfs:// protocol
1 parent f7d9f49 commit 0b57b6c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/resolve.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ async function resolve(uri: string, options?: ResolveOptions): Promise<ResolveOu
104104
// check to see if the link has the ipfs:// or ipns:// protocol/scheme
105105
else if ((uri as string).startsWith("ipfs://") || (uri as string).startsWith("ipns://")) {
106106

107-
const cidWithOptionalPath = (uri as string).substring(8);
107+
const cidWithOptionalPath = (uri as string).substring(7);
108108

109109
// check to see if the CID after the ipfs protocal/scheme is valid
110110
if (!isIPFS.cid(cidWithOptionalPath) && !isIPFS.cidPath(cidWithOptionalPath)) {

src/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ describe("Tests the ipfs-race library.", () => {
3131
});
3232

3333
it("ipfs protocol with no path", async () => {
34-
const {response, urlResolvedFrom} = await resolve(`ipfs:///${testCidWithNoPath}`);
34+
const {response, urlResolvedFrom} = await resolve(`ipfs://${testCidWithNoPath}`);
3535
expect(await response.json(), urlResolvedFrom).to.deep.equal(testCidWithNoPathResult)
3636
});
3737

3838
it("ipfs protocol with path", async () => {
39-
const {response, urlResolvedFrom} = await resolve(`ipfs:///${testCidWithPath}`);
39+
const {response, urlResolvedFrom} = await resolve(`ipfs://${testCidWithPath}`);
4040
expect(await response.json(), urlResolvedFrom).to.deep.equal(testCidWithPathResult)
4141
});
4242

0 commit comments

Comments
 (0)