This updates the usrdir option to look in /Users/ rather than /home/ when running on macOS, as this is where users' home directories live on this OS.
It also updates the config file's description of the option to hopefully be home directory agnostic.
---
config.toml | 2 +-src/main.rs | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/config.toml b/config.toml
index 8d1a9e4..b9533ba 100644
--- a/config.toml+++ b/config.toml
@@ -28,7 +28,7 @@ cgipath = "/path/to/cgi-bin/"
scgi = { "/scgi" = "localhost:4000" }
# cgienv is optional
cgienv = { "GIT_PROJECT_ROOT" = "/srv/git" }
-# usrdir is optional. it'll look in /home/usr/public_gemini+# usrdir is optional. it'll look in each user's ~/public_geminiusrdir = true
# proxy is optional
# path is what comes after the hostname e.g. example.com/path
diff --git a/src/main.rs b/src/main.rs
index 9edcc3a..0a4272d 100644
--- a/src/main.rs+++ b/src/main.rs
@@ -311,7 +311,11 @@ async fn handle_connection(
if url.path().starts_with("/~") && srv.server.usrdir.unwrap_or(false) {
let usr = url.path().trim_start_matches("/~");
let usr: Vec<&str> = usr.splitn(2, "/").collect();
- path.push("/home/");+ if cfg!(target_os = "macos") {+ path.push("/Users/");+ } else {+ path.push("/home/");+ } if usr.len() == 2 {
path.push(format!("{}/{}/{}", usr[0], "public_gemini", util::url_decode(usr[1].as_bytes())));
} else {
--
2.24.3 (Apple Git-128)