Handle macOS user paths when running on macOS
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.
This commit is contained in:
@@ -28,7 +28,7 @@ cgipath = "/path/to/cgi-bin/"
|
|||||||
scgi = { "/scgi" = "localhost:4000" }
|
scgi = { "/scgi" = "localhost:4000" }
|
||||||
# cgienv is optional
|
# cgienv is optional
|
||||||
cgienv = { "GIT_PROJECT_ROOT" = "/srv/git" }
|
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_gemini
|
||||||
usrdir = true
|
usrdir = true
|
||||||
# proxy is optional
|
# proxy is optional
|
||||||
# path is what comes after the hostname e.g. example.com/path
|
# path is what comes after the hostname e.g. example.com/path
|
||||||
|
|||||||
@@ -311,7 +311,11 @@ async fn handle_connection(
|
|||||||
if url.path().starts_with("/~") && srv.server.usrdir.unwrap_or(false) {
|
if url.path().starts_with("/~") && srv.server.usrdir.unwrap_or(false) {
|
||||||
let usr = url.path().trim_start_matches("/~");
|
let usr = url.path().trim_start_matches("/~");
|
||||||
let usr: Vec<&str> = usr.splitn(2, "/").collect();
|
let usr: Vec<&str> = usr.splitn(2, "/").collect();
|
||||||
|
if cfg!(target_os = "macos") {
|
||||||
|
path.push("/Users/");
|
||||||
|
} else {
|
||||||
path.push("/home/");
|
path.push("/home/");
|
||||||
|
}
|
||||||
if usr.len() == 2 {
|
if usr.len() == 2 {
|
||||||
path.push(format!("{}/{}/{}", usr[0], "public_gemini", util::url_decode(usr[1].as_bytes())));
|
path.push(format!("{}/{}/{}", usr[0], "public_gemini", util::url_decode(usr[1].as_bytes())));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user