From 7acc7a03a81fd237cba41aa2c90de11201588862 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 2 Apr 2025 21:03:01 +0200 Subject: [PATCH] Update JSON loader in search tests --- tests/rendered_output.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index beb83ebd..ab69a359 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -773,9 +773,10 @@ mod search { fn read_book_index(root: &Path) -> serde_json::Value { let index = root.join("book/searchindex.js"); let index = fs::read_to_string(index).unwrap(); - let index = index.trim_start_matches("Object.assign(window.search, "); - let index = index.trim_end_matches(");"); - serde_json::from_str(index).unwrap() + let index = index.trim_start_matches("window.search = JSON.parse('"); + let index = index.trim_end_matches("');"); + // We need unescape the string as it's supposed to be an escaped JS string. + serde_json::from_str(&index.replace("\\'", "'").replace("\\\\", "\\")).unwrap() } #[test]