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

Commit

Permalink
fix: handle subdomains for ipfs.dns (#1933)
Browse files Browse the repository at this point in the history
  • Loading branch information
niinpatel authored and Alan Shaw committed Mar 20, 2019
1 parent 6692d9c commit 29072a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/runtime/dns-nodejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const errcode = require('err-code')
module.exports = (domain, opts, callback) => {
resolveDnslink(domain)
.catch(err => {
// If the code is not ENOTFOUND or ERR_DNSLINK_NOT_FOUND then throw the error
if (err.code !== 'ENOTFOUND' && err.code !== 'ERR_DNSLINK_NOT_FOUND') throw err
// If the code is not ENOTFOUND or ERR_DNSLINK_NOT_FOUND or ENODATA then throw the error
if (err.code !== 'ENOTFOUND' && err.code !== 'ERR_DNSLINK_NOT_FOUND' && err.code !== 'ENODATA') throw err

if (domain.startsWith('_dnslink.')) {
// The supplied domain contains a _dnslink component
Expand Down
16 changes: 16 additions & 0 deletions test/cli/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,20 @@ describe('dns', () => runOnAndOff((thing) => {
expect(res.substr(0, 6)).to.eql('/ipns/')
})
})

it('resolve subdomain docs.ipfs.io dns', function () {
this.timeout(60 * 1000)

return ipfs('dns docs.ipfs.io').then(res => {
expect(res.substr(0, 6)).to.eql('/ipfs/')
})
})

it('resolve subdomain _dnslink.docs.ipfs.io dns', function () {
this.timeout(60 * 1000)

return ipfs('dns _dnslink.docs.ipfs.io').then(res => {
expect(res.substr(0, 6)).to.eql('/ipfs/')
})
})
}))

0 comments on commit 29072a5

Please sign in to comment.