Skip to content

Commit

Permalink
stable stringify
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza K committed Dec 7, 2020
1 parent b5b0895 commit f14f042
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion x-pack/plugins/data_enhanced/server/search/session/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { createHash } from 'crypto';
import stringify from 'json-stable-stringify';

/**
* Generate the hash for this request so that, in the future, this hash can be used to look up
Expand All @@ -13,5 +14,5 @@ import { createHash } from 'crypto';
*/
export function createRequestHash(keys: Record<any, any>) {
const { preference, ...params } = keys;
return createHash(`sha256`).update(JSON.stringify(params)).digest('hex');
return createHash(`sha256`).update(stringify(params)).digest('hex');
}

0 comments on commit f14f042

Please sign in to comment.