Update JSON loader in search tests
This commit is contained in:
parent
0ed1cbe486
commit
7acc7a03a8
1 changed files with 4 additions and 3 deletions
|
|
@ -773,9 +773,10 @@ mod search {
|
||||||
fn read_book_index(root: &Path) -> serde_json::Value {
|
fn read_book_index(root: &Path) -> serde_json::Value {
|
||||||
let index = root.join("book/searchindex.js");
|
let index = root.join("book/searchindex.js");
|
||||||
let index = fs::read_to_string(index).unwrap();
|
let index = fs::read_to_string(index).unwrap();
|
||||||
let index = index.trim_start_matches("Object.assign(window.search, ");
|
let index = index.trim_start_matches("window.search = JSON.parse('");
|
||||||
let index = index.trim_end_matches(");");
|
let index = index.trim_end_matches("');");
|
||||||
serde_json::from_str(index).unwrap()
|
// We need unescape the string as it's supposed to be an escaped JS string.
|
||||||
|
serde_json::from_str(&index.replace("\\'", "'").replace("\\\\", "\\")).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue