From 1c3d568254927cedb163012e2d79d35bb96b1601 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..9ae1bcb98 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; + let start = key.indexOf('!'); + return key.substring(start+1, end); } /* uses internal realtime knowledge of the format of the connection key to