Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 8b89df1

Browse files
niinpatelAlan Shaw
authored and
Alan Shaw
committed
test: tests and updated documentation for recursive dns (#455)
* test: tests for recursive dns * docs: update documentation for ipfs.dns
1 parent 89255d5 commit 8b89df1

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

SPEC/MISCELLANEOUS.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,14 @@ A great source of [examples](https://github.com/ipfs/interface-ipfs-core/blob/ma
5959

6060
> Resolve DNS links
6161
62-
##### `ipfs.dns(domain, [callback])`
62+
##### `ipfs.dns(domain, [options], [callback])`
6363

64-
`callback` must follow `function (err, path) {}` signature, where `err` is an error if the operation was not successful. `path` is the IPFS path for that domain.
64+
Where:
65+
66+
- `options` is an optional object argument that might include the following properties:
67+
- `recursive` (boolean, default true): resolve until result is not a domain name
68+
69+
- `callback` must follow `function (err, path) {}` signature, where `err` is an error if the operation was not successful. `path` is the IPFS path for that domain.
6570

6671
If no `callback` is passed, a promise is returned.
6772

src/miscellaneous/dns.js

+23
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,28 @@ module.exports = (createCommon, options) => {
4040
done()
4141
})
4242
})
43+
44+
// skipping because there is an error in https://ipfs.io/api/v0/dns?arg=ipfs.io
45+
// unskip when it is resolved and the new version released: https://github.com/ipfs/go-ipfs/issues/6086
46+
it.skip('should non-recursively resolve ipfs.io', () => {
47+
return ipfs.dns('ipfs.io', { recursive: false }).then(res => {
48+
// matches pattern /ipns/<ipnsaddress>
49+
expect(res).to.match(/\/ipns\/.+$/)
50+
})
51+
})
52+
53+
it('should recursively resolve ipfs.io', () => {
54+
return ipfs.dns('ipfs.io', { recursive: true }).then(res => {
55+
// matches pattern /ipfs/<hash>
56+
expect(res).to.match(/\/ipfs\/.+$/)
57+
})
58+
})
59+
60+
it('should resolve subdomain docs.ipfs.io', () => {
61+
return ipfs.dns('docs.ipfs.io').then(res => {
62+
// matches pattern /ipfs/<hash>
63+
expect(res).to.match(/\/ipfs\/.+$/)
64+
})
65+
})
4366
})
4467
}

0 commit comments

Comments
 (0)