Skip to content

Commit

Permalink
Support reproducible builds by forcing window.search to use stable ke…
Browse files Browse the repository at this point in the history
…y ordering. (rust-lang#692)
  • Loading branch information
tcr authored and Michael-F-Bryan committed May 14, 2018
1 parent bbdae05 commit 5578d95
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/renderer/html_handlebars/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 5578d95

Please sign in to comment.