diff --git a/package.json b/package.json index 421be13..543e6a6 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "util": "^0.12.3" }, "dependencies": { - "multiaddr": "^8.0.0" + "multiaddr": "^9.0.1" }, "contributors": [ "David Dias ", diff --git a/src/index.js b/src/index.js index b2a6c49..15e8cc8 100644 --- a/src/index.js +++ b/src/index.js @@ -146,9 +146,9 @@ exports.IPFS = P2P function makeMatchesFunction (partialMatch) { return function matches (a) { - if (!multiaddr.isMultiaddr(a)) { + if (!multiaddr.Multiaddr.isMultiaddr(a)) { try { - a = multiaddr(a) + a = new multiaddr.Multiaddr(a) } catch (err) { // catch error return false // also if it's invalid it's propably not matching as well so return false } @@ -224,7 +224,7 @@ function base (n) { function matches (a) { if (typeof a === 'string') { try { - a = multiaddr(a) + a = new multiaddr.Multiaddr(a) } catch (err) { // catch error return false // also if it's invalid it's propably not matching as well so return false } diff --git a/test/index.spec.js b/test/index.spec.js index 7a1e9e6..e38d5d8 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -196,7 +196,7 @@ describe('multiaddr validation', function () { test.forEach(function (testcase) { try { expect(p.matches(testcase), `assertMatches: ${testcase} (string)`).to.be.eql(true) - const ma = multiaddr(testcase) + const ma = new multiaddr.Multiaddr(testcase) expect(p.matches(ma), `assertMatches: ${testcase} (multiaddr object)`).to.be.eql(true) expect(p.matches(ma.bytes), `assertMatches: ${testcase} (multiaddr.bytes)`).to.be.eql(true) } catch (err) { @@ -217,7 +217,7 @@ describe('multiaddr validation', function () { try { // if testcase string happens to be a valid multiaddr, // we expect 'p' test to also return false for Multiaddr object and Uint8Array versions - validMultiaddrObj = multiaddr(testcase) + validMultiaddrObj = new multiaddr.Multiaddr(testcase) } catch (e) { // Ignoring testcase as the string is not a multiaddr // (There is a separate 'Uint8Array is invalid' test later below)