Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

place-contrib: sort the request id's parts with an explicit code-unit compare

Maurice3f2dec6c4707
diff --git a/server/src/nest/place-contrib/place-contrib.helpers.ts b/server/src/nest/place-contrib/place-contrib.helpers.ts
index adb391208..7eea3eb7d 100644
--- a/server/src/nest/place-contrib/place-contrib.helpers.ts
+++ b/server/src/nest/place-contrib/place-contrib.helpers.ts
@@ -133,9 +133,12 @@ export function baseHashOf(value: string | null | undefined): string | null {
* retry after a lost answer is recognised as the same contribution, and new
* as soon as one of them was replaced.
*/
+/** Plain code-unit order: the same on every server, where a locale's collation is not. */
+const byCodeUnit = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);
+
export function requestCid(entryCids: readonly string[]): string {
const digest = createHash('sha256')
- .update([...entryCids].sort().join(','))
+ .update([...entryCids].sort(byCodeUnit).join(','))
.digest('base64url');
return digest.slice(0, 32);
}