Skip to content

Commit 7acc7a0

Browse files
Update JSON loader in search tests
1 parent 0ed1cbe commit 7acc7a0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/rendered_output.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,9 +773,10 @@ mod search {
773773
fn read_book_index(root: &Path) -> serde_json::Value {
774774
let index = root.join("book/searchindex.js");
775775
let index = fs::read_to_string(index).unwrap();
776-
let index = index.trim_start_matches("Object.assign(window.search, ");
777-
let index = index.trim_end_matches(");");
778-
serde_json::from_str(index).unwrap()
776+
let index = index.trim_start_matches("window.search = JSON.parse('");
777+
let index = index.trim_end_matches("');");
778+
// We need unescape the string as it's supposed to be an escaped JS string.
779+
serde_json::from_str(&index.replace("\\'", "'").replace("\\\\", "\\")).unwrap()
779780
}
780781

781782
#[test]

0 commit comments

Comments
 (0)