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

Commit 1516328

Browse files
committed
fix: handle subdomains for ipfs.dns
1 parent 3ef1ed4 commit 1516328

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/core/runtime/dns-nodejs.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ const errcode = require('err-code')
77
module.exports = (domain, opts, callback) => {
88
resolveDnslink(domain)
99
.catch(err => {
10-
// If the code is not ENOTFOUND or ERR_DNSLINK_NOT_FOUND then throw the error
11-
if (err.code !== 'ENOTFOUND' && err.code !== 'ERR_DNSLINK_NOT_FOUND') throw err
10+
// If the code is not ENOTFOUND or ERR_DNSLINK_NOT_FOUND or ENODATA then throw the error
11+
if (err.code !== 'ENOTFOUND' && err.code !== 'ERR_DNSLINK_NOT_FOUND' && err.code !== 'ENODATA') {
12+
throw err
13+
}
1214

1315
if (domain.startsWith('_dnslink.')) {
1416
// The supplied domain contains a _dnslink component

test/cli/dns.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,20 @@ describe('dns', () => runOnAndOff((thing) => {
2727
expect(res.substr(0, 6)).to.eql('/ipns/')
2828
})
2929
})
30+
31+
it('resolve subdomain docs.ipfs.io dns', function () {
32+
this.timeout(60 * 1000)
33+
34+
return ipfs('dns docs.ipfs.io').then(res => {
35+
expect(res.substr(0, 6)).to.eql('/ipfs/')
36+
})
37+
})
38+
39+
it('resolve subdomain _dnslink.docs.ipfs.io dns', function () {
40+
this.timeout(60 * 1000)
41+
42+
return ipfs('dns _dnslink.docs.ipfs.io').then(res => {
43+
expect(res.substr(0, 6)).to.eql('/ipfs/')
44+
})
45+
})
3046
}))

0 commit comments

Comments
 (0)