Support reproducible builds by forcing window.search to use stable key ordering. (#692)

This commit is contained in:
Tim Ryan 2018-05-14 06:22:21 -04:00 committed by Michael Bryan
parent 7ee5b6643b
commit b9ca108fca
1 changed files with 4 additions and 0 deletions

View File

@ -205,6 +205,10 @@ fn write_to_js(index: Index, search_config: &Search) -> Result<String> {
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))