fix: doc-wasm hardcoded path momentry_core_0.1 -> momentry_core

This commit is contained in:
Accusys
2026-05-22 09:33:33 +08:00
parent 0794476902
commit 7805eaa3cb
+2 -2
View File
@@ -9,7 +9,7 @@ async fn doc_redirect() -> axum::response::Redirect {
async fn wasm_doc_handler() -> Result<impl axum::response::IntoResponse, (StatusCode, &'static str)> async fn wasm_doc_handler() -> Result<impl axum::response::IntoResponse, (StatusCode, &'static str)>
{ {
let path = let path =
std::path::Path::new("/Users/accusys/momentry_core_0.1/docs_v1.0/doc_wasm/index.html"); std::path::Path::new("/Users/accusys/momentry_core/docs_v1.0/doc_wasm/index.html");
match tokio::fs::read_to_string(path).await { match tokio::fs::read_to_string(path).await {
Ok(html) => Ok(([("content-type", "text/html; charset=utf-8")], html)), Ok(html) => Ok(([("content-type", "text/html; charset=utf-8")], html)),
Err(_) => Err((StatusCode::NOT_FOUND, "Doc not found")), Err(_) => Err((StatusCode::NOT_FOUND, "Doc not found")),
@@ -22,7 +22,7 @@ async fn wasm_doc_file_handler(
if file.contains("..") || file.contains("//") { if file.contains("..") || file.contains("//") {
return Err((StatusCode::NOT_FOUND, "Invalid path")); return Err((StatusCode::NOT_FOUND, "Invalid path"));
} }
let base = std::path::Path::new("/Users/accusys/momentry_core_0.1/docs_v1.0/doc_wasm"); let base = std::path::Path::new("/Users/accusys/momentry_core/docs_v1.0/doc_wasm");
let path = base.join(&file); let path = base.join(&file);
if !path.exists() || !path.starts_with(base) { if !path.exists() || !path.starts_with(base) {
return Err((StatusCode::NOT_FOUND, "File not found")); return Err((StatusCode::NOT_FOUND, "File not found"));