Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missed the protoCodes called, now fixed #11

Merged
merged 1 commit into from
Mar 12, 2016
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
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var extend = require('xtend')
var codec = require('./codec')
var protocols = require('./protocols')
var NotImplemented = new Error('Sorry, Not Implemented Yet.')
var varint = require('varint')

exports = module.exports = Multiaddr

Expand Down Expand Up @@ -52,6 +53,7 @@ Multiaddr.prototype.inspect = function inspect () {
// get the multiaddr protocols
Multiaddr.prototype.protos = function protos () {
return map(this.protoCodes(), function (code) {
console.log('->', code)
return extend(protocols(code))
// copy to prevent users from modifying the internal objs.
})
Expand All @@ -69,8 +71,9 @@ Multiaddr.prototype.protos = function protos () {
Multiaddr.prototype.protoCodes = function protoCodes () {
var codes = []
for (var i = 0; i < this.buffer.length; i++) {
var code = 0 + this.buffer[i]
var code = varint.decode(this.buffer, i)
var size = protocols(code).size / 8
i = i + varint.decode.bytes - 1
i += size // skip over proto data
codes.push(code)
}
Expand Down
1 change: 1 addition & 0 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ describe('variants', () => {
const str = '/ip6/2001:8a0:7ac5:4201:3ac9:86ff:fe31:7095/udp/5000/utp'
const addr = multiaddr(str)
expect(addr).to.have.property('buffer')
expect(addr.protoNames())
expect(addr.toString()).to.equal(str)
done()
})
Expand Down