Skip to content

Commit

Permalink
Fix parsed is null error (#1535)
Browse files Browse the repository at this point in the history
* Fix parsed is null error

* Update CHANGELOG
  • Loading branch information
tomaka authored Apr 9, 2020
1 parent 80ea2f6 commit 8adf474
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
- `libp2p-floodsub`: Allow sent messages seen as subscribed.
[PR 1520](https://github.com/libp2p/rust-libp2p/pull/1520)

- `libp2p-wasm-ext`: Fix "parsed is null" errors being thrown.
[PR 1535](https://github.com/libp2p/rust-libp2p/pull/1535)

# Version 0.17.0 (2020-04-02)

- `libp2p-core`: Finished "identity hashing" for peer IDs migration.
Expand Down
10 changes: 5 additions & 5 deletions transports/wasm-ext/src/websockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ export const websocket_transport = () => {
// TODO: support dns addresses as well
const multiaddr_to_ws = (addr) => {
let parsed = addr.match(/^\/(ip4|ip6|dns4|dns6)\/(.*?)\/tcp\/(.*?)\/(ws|wss|x-parity-ws\/(.*)|x-parity-wss\/(.*))$/);
let proto = 'wss';
if (parsed[4] == 'ws' || parsed[4] == 'x-parity-ws') {
proto = 'ws';
}
let url = decodeURIComponent(parsed[5] || parsed[6] || '');
if (parsed != null) {
let proto = 'wss';
if (parsed[4] == 'ws' || parsed[4] == 'x-parity-ws') {
proto = 'ws';
}
let url = decodeURIComponent(parsed[5] || parsed[6] || '');
if (parsed[1] == 'ip6') {
return proto + "://[" + parsed[2] + "]:" + parsed[3] + url;
} else {
Expand Down

0 comments on commit 8adf474

Please sign in to comment.