Skip to content
Draft
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
6 changes: 4 additions & 2 deletions src/libs/compoundParamsKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ function normalizeForKey(value: unknown): unknown {
}
if (typeof value === 'object') {
// Recursively sort so differently-ordered nested keys produce the same compound.
const entries = Object.entries(value as Record<string, unknown>)
const objectEntries: Array<[string, unknown]> = Object.entries(value);
const entries = objectEntries
.sort(([a], [b]) => {
if (a < b) {
return -1;
Expand All @@ -49,7 +50,8 @@ function compoundParamsKey(routeKey: string, params: unknown): string {
return `${routeKey}${COMPOUND_KEY_DELIMITER}${JSON.stringify(normalizeForKey(params))}`;
}
// Explicit-undefined fields must match path-rehydrated (omitted) params.
const entries = Object.entries(params as Record<string, unknown>)
const objectEntries: Array<[string, unknown]> = Object.entries(params);
const entries = objectEntries
.filter(([, value]) => value !== undefined)
.map(([k, v]) => [k, normalizeForKey(v)] as const)
.sort(([a], [b]) => {
Expand Down
Loading