fix: remove buggy node polyfill plugin (#18531)
* fix: remove buggy node polyfill plugin * fix websocket test * remove assert dependency
This commit is contained in:
8
web3.js/src/util/assert.ts
Normal file
8
web3.js/src/util/assert.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export default function (
|
||||
condition: unknown,
|
||||
message?: string,
|
||||
): asserts condition {
|
||||
if (!condition) {
|
||||
throw new Error(message || 'Assertion failed');
|
||||
}
|
||||
}
|
@@ -1,7 +1,5 @@
|
||||
import {format as urlFormat, parse as urlParse} from 'url';
|
||||
|
||||
export function makeWebsocketUrl(endpoint: string) {
|
||||
let url = urlParse(endpoint);
|
||||
let url = new URL(endpoint);
|
||||
const useHttps = url.protocol === 'https:';
|
||||
|
||||
url.protocol = useHttps ? 'wss:' : 'ws:';
|
||||
@@ -13,8 +11,8 @@ export function makeWebsocketUrl(endpoint: string) {
|
||||
// When the endpoint omits the port, we're connecting to the protocol
|
||||
// default ports: http(80) or https(443) and it's assumed we're behind a reverse
|
||||
// proxy which manages WebSocket upgrade and backend port redirection.
|
||||
if (url.port !== null) {
|
||||
if (url.port !== '') {
|
||||
url.port = String(Number(url.port) + 1);
|
||||
}
|
||||
return urlFormat(url);
|
||||
return url.toString();
|
||||
}
|
||||
|
Reference in New Issue
Block a user