From 892a4b84014019b55cd452f7c2cee6c0e651a7f0 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Mon, 28 Aug 2023 23:07:01 +0200 Subject: [PATCH] Fix parsing of server version. --- static/protocol.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/static/protocol.js b/static/protocol.js index cd4c6cc..99b6e4f 100644 --- a/static/protocol.js +++ b/static/protocol.js @@ -298,7 +298,7 @@ ServerConnection.prototype.connect = async function(url) { this.socket.onopen = function(e) { sc.send({ type: 'handshake', - version: ["2"], + version: ['2'], id: sc.id, }); if(sc.onconnected) @@ -332,9 +332,10 @@ ServerConnection.prototype.connect = async function(url) { let m = JSON.parse(e.data); switch(m.type) { case 'handshake': { - if(m.version === "2") - sc.version = m.version; - else { + if((m.version instanceof Array) && m.version.includes('2')) { + sc.version = '2'; + } else { + sc.version = null; console.error(`Unknown protocol version ${m.version}`); throw new Error(`Unknown protocol version ${m.version}`); }