Fix the multiaddr parsing in the JS snippet (#1824)

* Fix the multiaddr parsing in the JS snippet

* Update CHANGELOG
This commit is contained in:
Pierre Krieger
2020-11-06 09:46:47 +01:00
committed by GitHub
parent 2ba78b4ce7
commit b482833c3c
2 changed files with 2 additions and 1 deletions

View File

@ -1,5 +1,6 @@
# 0.24.0 [unreleased]
- Fix the WebSocket implementation parsing `x-parity-ws` multiaddresses as `x-parity-wss`.
- Update dependencies.
# 0.23.0 [2020-10-16]

View File

@ -34,7 +34,7 @@ const multiaddr_to_ws = (addr) => {
let parsed = addr.match(/^\/(ip4|ip6|dns4|dns6|dns)\/(.*?)\/tcp\/(.*?)\/(ws|wss|x-parity-ws\/(.*)|x-parity-wss\/(.*))$/);
if (parsed != null) {
let proto = 'wss';
if (parsed[4] == 'ws' || parsed[4] == 'x-parity-ws') {
if (parsed[4] == 'ws' || parsed[4].startsWith('x-parity-ws/')) {
proto = 'ws';
}
let url = decodeURIComponent(parsed[5] || parsed[6] || '');