From 46823bcb09b6d08d9676bba4e0f8a00c5c66e338 Mon Sep 17 00:00:00 2001 From: amnon Date: Tue, 22 Oct 2024 20:05:24 +0100 Subject: [PATCH] Testing: handle case when connectionKey contains more than one '-' --- test/browser/connection.test.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/browser/connection.test.js b/test/browser/connection.test.js index 382086e1e..1561f806a 100644 --- a/test/browser/connection.test.js +++ b/test/browser/connection.test.js @@ -218,13 +218,16 @@ define(['shared_helper', 'chai'], function (Helper, chai) { /* connectionKey has the form !- */ /* remove the handleID from the end of key */ - let k = key.split('-')[0]; + const lastIndex = key.lastIndexOf('-'); + if (lastIndex !== -1) { + key = key.slice(0, lastIndex); + } /* skip the server instanceID if present, as reconnects may be routed to different frontends */ - if (k.includes('!')) { - k = k.split('!')[1]; + if (key.includes('!')) { + key = key.split('!')[1]; } - return k; + return key; } /* uses internal realtime knowledge of the format of the connection key to