From e50d31479cb4aa40f5fb1620bb09445a180203e0 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Mon, 30 Dec 2024 23:21:48 +0100 Subject: [PATCH] fix --- src/archive.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index f2aa3f4..39e2a91 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -1,4 +1,4 @@ -use std::path::PathBuf; +use std::{io::Read, path::PathBuf}; use based::request::RequestContext; use maud::html; @@ -189,17 +189,23 @@ impl Document { format!("index_{version}.html") } else { let versions = self.versions(); - versions.first().cloned()? + let version = versions.first().cloned()?; + format!("index_{version}.html") }; - file_path = file_path.join(format!("index_{}.html", latest_version)); + file_path = file_path.join(latest_version); - let content = std::fs::read_to_string(file_path).ok()?; + let mut buf = Vec::new(); + std::fs::File::open(file_path) + .unwrap() + .read_to_end(&mut buf) + .unwrap(); + let content = String::from_utf8_lossy(&buf); if std::env::var("ROUTE_INTERNAL").unwrap_or("false".to_string()) == "true" { Some(internalize_urls(&content)) } else { - Some(content) + Some(content.to_string()) } }