mirror of
https://github.com/fluencelabs/js-mafmt
synced 2025-04-25 15:22:38 +00:00
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
This commit is contained in:
parent
41a8a85e6a
commit
2f336e3873
@ -38,7 +38,7 @@
|
||||
"pre-commit": "^1.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"multiaddr": "^3.0.0"
|
||||
"multiaddr": "^3.0.1"
|
||||
},
|
||||
"contributors": [
|
||||
"David Dias <daviddias.p@gmail.com>",
|
||||
|
11
src/index.js
11
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
|
||||
|
@ -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 () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user