Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing: handle case when connectionKey contains more than one '-' #1903

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions test/browser/connection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,16 @@ define(['shared_helper', 'chai'], function (Helper, chai) {
/* connectionKey has the form <instanceID>!<hmac>-<handleID> */

/* 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think key is never declared now?
should add let key; before if statement

Copy link
Contributor Author

@amnonbc amnonbc Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in line 217, it is declared as a parameter of function connectionHmac?

Copy link
Contributor

@VeskeR VeskeR Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, sorry, it was outside of the visible diff, didn't see it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do think we should revert back to let k ... return k - it's bad practice to mutate arguments like this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do think we should revert back to let k ... return k - it's bad practice to mutate arguments like this

agree

}

/* 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
Expand Down
Loading