Skip to content

Commit

Permalink
test/browser/connection: fix hmac extraction
Browse files Browse the repository at this point in the history
Relax the connectionKey hmac extraction and account for
the possibilities of multiple - characters.

RAR-655
  • Loading branch information
Zariel committed Jan 7, 2025
1 parent 1d6483a commit e00b283
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions test/browser/connection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,9 @@ define(['shared_helper', 'chai'], function (Helper, chai) {
// strip instanceID and handleID from connectionKey */
function connectionHmac(key) {
/* connectionKey has the form <instanceID>!<hmac>-<handleID> */

/* 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];
}
return k;
const end = key.lastIndexOf('-');
let start = key.indexOf('!');
return key.substring(start + 1, end);
}

/* uses internal realtime knowledge of the format of the connection key to
Expand Down

0 comments on commit e00b283

Please sign in to comment.