From e2e2f74dbe83098070d84f054544809abab029f2 Mon Sep 17 00:00:00 2001 From: Chris Bannister Date: Tue, 7 Jan 2025 11:25:46 +0000 Subject: [PATCH] test/browser/connection: fix hmac extraction Relax the connectionKey hmac extraction and account for the possibilities of multiple - characters. RAR-655 --- test/browser/connection.test.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test/browser/connection.test.js b/test/browser/connection.test.js index 382086e1e..b755e1b2a 100644 --- a/test/browser/connection.test.js +++ b/test/browser/connection.test.js @@ -216,15 +216,12 @@ define(['shared_helper', 'chai'], function (Helper, chai) { // strip instanceID and handleID from connectionKey */ function connectionHmac(key) { /* connectionKey has the form !- */ - - /* remove the handleID from the end of key */ - let k = key.split('-')[0]; - - /* skip the server instanceID if present, as reconnects may be routed to different frontends */ - if (k.includes('!')) { - k = k.split('!')[1]; + let end = key.lastIndexOf('-'); + if (end < 0) { + end = key.length; } - return k; + const start = key.indexOf('!'); + return key.substring(start + 1, end); } /* uses internal realtime knowledge of the format of the connection key to