Skip to content

Commit 080936f

Browse files
authored
fix: match websocket addresses that include a peer id (#156)
Update `WebSockets` and `WebSocketsSecure` to also match websocket addresses that end in `/p2p/Qmfoo`.
1 parent 7cb7281 commit 080936f

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/index.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,28 @@ export const UTP = and(UDP, base('utp'))
3535
export const QUIC = and(UDP, base('quic'))
3636
export const QUICV1 = and(UDP, base('quic-v1'))
3737

38-
export const WebSockets = or(
38+
const _WebSockets = or(
3939
and(TCP, base('ws')),
4040
and(DNS, base('ws'))
4141
)
4242

43-
export const WebSocketsSecure = or(
43+
export const WebSockets = or(
44+
_WebSockets,
45+
and(_WebSockets, base('p2p'))
46+
)
47+
48+
const _WebSocketsSecure = or(
4449
and(TCP, base('wss')),
4550
and(DNS, base('wss')),
4651
and(TCP, base('tls'), base('ws')),
4752
and(DNS, base('tls'), base('ws'))
4853
)
4954

55+
export const WebSocketsSecure = or(
56+
_WebSocketsSecure,
57+
and(_WebSocketsSecure, base('p2p'))
58+
)
59+
5060
export const HTTP = or(
5161
and(TCP, base('http')),
5262
and(IP, base('http')),
@@ -99,8 +109,8 @@ export const P2PWebRTCDirect = or(
99109
)
100110

101111
export const Reliable = or(
102-
WebSockets,
103-
WebSocketsSecure,
112+
_WebSockets,
113+
_WebSocketsSecure,
104114
HTTP,
105115
HTTPS,
106116
P2PWebRTCStar,

0 commit comments

Comments
 (0)