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

fix: handle subdomains for ipfs.dns #1933

Merged
merged 1 commit into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/')
})
})
}))