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

Commit 038f37e

Browse files
committedFeb 28, 2016
Allow direct listings of hashes for pin.ls
1 parent 9bfde1b commit 038f37e

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed
 

‎src/api/pin.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,16 @@ module.exports = (send) => {
2424
type = null
2525
}
2626
let opts = null
27-
if (type) opts = { type: type }
28-
return send('pin/ls', null, opts, null, cb)
27+
let hash = null
28+
if (typeof type === 'string') {
29+
opts = { type: type }
30+
} else if (type && type.hash) {
31+
hash = type.hash
32+
type.hash = null
33+
opts = type
34+
}
35+
36+
return send('pin/ls', hash, opts, null, cb)
2937
}
3038
}
3139
}

‎test/api/pin.spec.js

+17
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ describe('.pin', () => {
1717
})
1818
})
1919

20+
it('.pin.list hash', (done) => {
21+
apiClients['b'].pin.list({hash: 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'}, (err, res) => {
22+
expect(err).to.not.exist
23+
expect(res).to.exist
24+
done()
25+
})
26+
})
27+
2028
it('.pin.remove', (done) => {
2129
apiClients['b'].pin.remove('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', {recursive: false}, (err, res) => {
2230
expect(err).to.not.exist
@@ -46,6 +54,15 @@ describe('.pin', () => {
4654
})
4755
})
4856

57+
it('.pin.list hash', () => {
58+
return apiClients['b'].pin.list({
59+
hash: 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
60+
})
61+
.then((res) => {
62+
expect(res).to.exist
63+
})
64+
})
65+
4966
it('.pin.remove', () => {
5067
return apiClients['b'].pin
5168
.remove('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', {recursive: false})

0 commit comments

Comments
 (0)
This repository has been archived.