Skip to content

Commit d531f13

Browse files
committed
Make add_params_to_url template function deterministic
1 parent ab52f7e commit d531f13

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

crates/templates/src/functions.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! Additional functions, tests and filters used in templates
1111
1212
use std::{
13-
collections::HashMap,
13+
collections::{BTreeMap, HashMap},
1414
fmt::Formatter,
1515
str::FromStr,
1616
sync::{Arc, atomic::AtomicUsize},
@@ -182,7 +182,8 @@ fn function_add_params_to_url(
182182
.unwrap_or_default();
183183

184184
// Merge the exising and the additional parameters together
185-
let params: HashMap<&String, &Value> = params.iter().chain(existing.iter()).collect();
185+
// Use a BTreeMap for determinism (because it orders keys)
186+
let params: BTreeMap<&String, &Value> = params.iter().chain(existing.iter()).collect();
186187

187188
// Transform them back to urlencoded
188189
let params = serde_urlencoded::to_string(params).map_err(|e| {

0 commit comments

Comments
 (0)