From 1744c892394b5b698892cb0a46fbd3e2c53f6b5c Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Mon, 27 Oct 2025 14:37:31 +0000 Subject: [PATCH] Make `add_params_to_url` template function deterministic --- crates/templates/src/functions.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/templates/src/functions.rs b/crates/templates/src/functions.rs index 631e4742e..c8943ebc0 100644 --- a/crates/templates/src/functions.rs +++ b/crates/templates/src/functions.rs @@ -10,7 +10,7 @@ //! Additional functions, tests and filters used in templates use std::{ - collections::HashMap, + collections::{BTreeMap, HashMap}, fmt::Formatter, str::FromStr, sync::{Arc, atomic::AtomicUsize}, @@ -182,7 +182,8 @@ fn function_add_params_to_url( .unwrap_or_default(); // Merge the exising and the additional parameters together - let params: HashMap<&String, &Value> = params.iter().chain(existing.iter()).collect(); + // Use a BTreeMap for determinism (because it orders keys) + let params: BTreeMap<&String, &Value> = params.iter().chain(existing.iter()).collect(); // Transform them back to urlencoded let params = serde_urlencoded::to_string(params).map_err(|e| {