From 2f336e3873708871300d0a3ef2b0c20d97407fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Wed, 6 Sep 2017 14:13:17 +0200 Subject: [PATCH] feat: Update to multiaddr v3.0.1 - refactor: websocket{s => }-star (#19) * chore: Update to multiaddr v3.0.1 - refactor: websocket{s => }-star * fix: Some valid websocket-star addresses were filtered as invalid --- package.json | 4 ++-- src/index.js | 11 ++++++----- test/index.spec.js | 14 ++++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 01554ef..58cfbba 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "pre-commit": "^1.2.2" }, "dependencies": { - "multiaddr": "^3.0.0" + "multiaddr": "^3.0.1" }, "contributors": [ "David Dias ", @@ -47,4 +47,4 @@ "dignifiedquire ", "dmitriy ryajov " ] -} \ No newline at end of file +} diff --git a/src/index.js b/src/index.js index 7062fc1..dd25ba0 100644 --- a/src/index.js +++ b/src/index.js @@ -44,10 +44,11 @@ const WebRTCStar = or( and(WebSocketsSecure, base('p2p-webrtc-star'), base('ipfs')) ) -const WebSocketsStar = or( - and(WebSockets, base('p2p-websockets-star')), - and(WebSockets, base('p2p-websockets-star'), base('ipfs')), - and(WebSocketsSecure, base('p2p-websockets-star'), base('ipfs')) +const WebSocketStar = or( + and(WebSockets, base('p2p-websocket-star'), base('ipfs')), + and(WebSocketsSecure, base('p2p-websocket-star'), base('ipfs')), + and(WebSockets, base('p2p-websocket-star')), + and(WebSocketsSecure, base('p2p-websocket-star')) ) const WebRTCDirect = and(HTTP, base('p2p-webrtc-direct')) @@ -102,7 +103,7 @@ exports.UTP = UTP exports.HTTP = HTTP exports.WebSockets = WebSockets exports.WebSocketsSecure = WebSocketsSecure -exports.WebSocketsStar = WebSocketsStar +exports.WebSocketStar = WebSocketStar exports.WebRTCStar = WebRTCStar exports.WebRTCDirect = WebRTCDirect exports.Reliable = Reliable diff --git a/test/index.spec.js b/test/index.spec.js index a52d9df..5026c3d 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -84,9 +84,11 @@ describe('multiaddr validation', function () { '/ip6/::/tcp/0/http/p2p-webrtc-direct' ] - const goodWebSocketsStar = [ - '/ip4/1.2.3.4/tcp/3456/ws/p2p-websockets-star', - '/ip6/::/tcp/0/ws/p2p-websockets-star' + const goodWebSocketStar = [ + '/ip4/1.2.3.4/tcp/3456/ws/p2p-websocket-star', + '/ip6/::/tcp/0/ws/p2p-websocket-star', + '/dns/localhost/ws/p2p-websocket-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4', + '/ip4/1.2.3.4/tcp/3456/ws/p2p-websocket-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4' ] const badWS = [ @@ -186,9 +188,9 @@ describe('multiaddr validation', function () { assertMismatches(mafmt.WebSocketsSecure, goodIP, badWSS, goodUDP, badWS) }) - it('WebSocketsStar validation', function () { - assertMatches(mafmt.WebSocketsStar, goodWebSocketsStar) - assertMismatches(mafmt.WebSocketsStar, goodIP, goodUDP, badWS) + it('WebSocketStar validation', function () { + assertMatches(mafmt.WebSocketStar, goodWebSocketStar) + assertMismatches(mafmt.WebSocketStar, goodIP, goodUDP, badWS) }) it('WebRTCStar validation', function () {