fix: remove buggy node polyfill plugin (#18531)

* fix: remove buggy node polyfill plugin

* fix websocket test

* remove assert dependency
This commit is contained in:
Justin Starry
2021-07-09 00:33:41 -05:00
committed by GitHub
parent f6371cce17
commit 2ef2b6daa0
12 changed files with 24 additions and 20 deletions

View File

@@ -0,0 +1,8 @@
export default function (
condition: unknown,
message?: string,
): asserts condition {
if (!condition) {
throw new Error(message || 'Assertion failed');
}
}

View File

@@ -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();
}