Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 03dcab9

Browse files
committed
feat: add support to ipns resolve /ipns/<fqdn>
fixes: #1918
1 parent 5044a30 commit 03dcab9

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"ipns": "~0.5.2",
114114
"is-domain-name": "^1.0.1",
115115
"is-ipfs": "~0.6.1",
116+
"is-domain-name": "^1.0.1",
116117
"is-pull-stream": "~0.0.0",
117118
"is-stream": "^2.0.0",
118119
"iso-url": "~0.4.6",

test/core/name.spec.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,4 +500,43 @@ describe('name', function () {
500500
done()
501501
})
502502
})
503+
504+
describe('working with dns', function () {
505+
let node
506+
let ipfsd
507+
508+
before(function (done) {
509+
df.spawn({
510+
exec: IPFS,
511+
args: [`--pass ${hat()}`, '--offline'],
512+
config: { Bootstrap: [] }
513+
}, (err, _ipfsd) => {
514+
expect(err).to.not.exist()
515+
ipfsd = _ipfsd
516+
node = _ipfsd.api
517+
done()
518+
})
519+
})
520+
521+
after((done) => ipfsd.stop(done))
522+
523+
it('should resolve ipfs.io', async () => {
524+
const r = await node.name.resolve('ipfs.io', { recursive: false })
525+
return expect(r).to.eq('/ipns/website.ipfs.io')
526+
})
527+
528+
it('should resolve /ipns/ipfs.io recursive', async () => {
529+
const r = await node.name.resolve('ipfs.io', { recursive: true })
530+
531+
return expect(r.substr(0, 6)).to.eql('/ipfs/')
532+
})
533+
534+
it('should fail to resolve /ipns/ipfs.a', async () => {
535+
try {
536+
await node.name.resolve('ipfs.a')
537+
} catch (err) {
538+
expect(err).to.exist()
539+
}
540+
})
541+
})
503542
})

0 commit comments

Comments
 (0)