Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
httpd: Try lowercase READMEs as well
cloudhead committed 2 years ago
commit 3f592e23d44cbc06451600591f37e65d6d0e57d9
parent 8d5299fe85c8a88d0604b4b21885585a0b567187
1 file changed +8 -4
modified radicle-httpd/src/api/v1/projects.rs
@@ -420,7 +420,7 @@ async fn readme_handler(
) -> impl IntoResponse {
    let storage = &ctx.profile.storage;
    let repo = Repository::open(paths::repository(storage, &project))?;
-
    let paths = &[
+
    let paths = [
        "README",
        "README.md",
        "README.markdown",
@@ -429,9 +429,13 @@ async fn readme_handler(
        "Readme.md",
    ];

-
    for path in paths {
-
        if let Ok(blob) = repo.blob(sha, path) {
-
            let response = api::json::blob(&blob, path);
+
    for path in paths
+
        .iter()
+
        .map(ToString::to_string)
+
        .chain(paths.iter().map(|p| p.to_lowercase()))
+
    {
+
        if let Ok(blob) = repo.blob(sha, &path) {
+
            let response = api::json::blob(&blob, &path);
            return Ok::<_, Error>(Json(response));
        }
    }