Skip to content

Commit

Permalink
fix: ensure serialized channel map keys are always identical (deep eq…
Browse files Browse the repository at this point in the history
…uality)
  • Loading branch information
codeofmochi committed Jun 24, 2021
1 parent 88ec19d commit 0dc7684
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ws/ws-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ function addToMappedArray<S, T>(map: Map<S, Array<T>>, key: S, value: T) {
* (deep equality) to serve as map keys
*/
function buildChannelKey(channel: Channel): string {
return JSON.stringify(channel);
// ensure serialized key is always identical (properties + order)
const rebuiltChannel: Channel = { name: channel.name, entity: channel.entity };
return JSON.stringify(rebuiltChannel);
};
function keyToChannel(key: string): Channel {
return JSON.parse(key);
Expand Down

0 comments on commit 0dc7684

Please sign in to comment.