From e931e895c0c986f6575e798e737f243fdd93c2f0 Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Sun, 13 May 2018 12:36:55 -0400 Subject: [PATCH] Support reproducible builds by forcing window.search to use stable key ordering. --- src/renderer/html_handlebars/search.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/renderer/html_handlebars/search.rs b/src/renderer/html_handlebars/search.rs index d49772f8b2..1ee66a5113 100644 --- a/src/renderer/html_handlebars/search.rs +++ b/src/renderer/html_handlebars/search.rs @@ -205,6 +205,10 @@ fn write_to_js(index: Index, search_config: &Search) -> Result { searchoptions, index, }; + + // By converting to serde_json::Value as an intermediary, we use a + // BTreeMap internally and can force a stable ordering of map keys. + let json_contents = serde_json::to_value(&json_contents)?; let json_contents = serde_json::to_string(&json_contents)?; Ok(format!("window.search = {};", json_contents))