From 9955f945ddaee76909a6b0f2afe0d60b69f6d9e5 Mon Sep 17 00:00:00 2001 From: Joep Meindertsma Date: Wed, 30 Nov 2022 12:24:30 +0100 Subject: [PATCH] Fix authenticate ws before connection bug --- lib/src/store.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/store.ts b/lib/src/store.ts index aad2ac8e..509077d7 100644 --- a/lib/src/store.ts +++ b/lib/src/store.ts @@ -411,7 +411,7 @@ export class Store { if (agent) { setCookieAuthentication(this, agent); this.webSockets.forEach(ws => { - authenticate(ws, this); + ws.readyState === ws.OPEN && authenticate(ws, this); }); this.resources.forEach(r => { if (r.isUnauthorized()) { @@ -425,7 +425,7 @@ export class Store { public setServerUrl(url: string): void { tryValidURL(url); - if (url.substr(-1) === '/') { + if (url.substring(-1) === '/') { throw Error('baseUrl should not have a trailing slash'); }