Skip to content

Commit ff1ae3a

Browse files
committed
Fix code and add logic for set order into body keys
1 parent 1dcbe32 commit ff1ae3a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/cache.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@ export const getCacheKey = async (props: GetCacheKeyProps): Promise<string> => {
1212
// https://stackoverflow.com/a/40924449
1313
const propsWithoutUndefined = Object.keys(props).reduce((acc, key) => {
1414
const _acc: Record<string, any> = acc;
15-
const propValue = (props as any)[key];
16-
if (propValue != null && propValue !== '') {
15+
let propValue = (props as any)[key];
16+
if (key === 'body' && propValue !== '') {
17+
try {
18+
const body = JSON.parse(propValue);
19+
propValue = JSON.stringify(body, Object.keys(body).sort());
20+
} catch (_error) {
21+
propValue = '';
22+
}
23+
}
24+
if (propValue !== null && propValue !== '') {
1725
_acc[key] = propValue;
1826
}
1927
return _acc;

0 commit comments

Comments
 (0)