}
fn sanitize_path(path: &str, uri_prefix: &str) -> String {
- encode_uri(&format!("{}{}", uri_prefix, path.trim_matches('/')))
+ let new_path = match (uri_prefix, path) {
+ ("/", "/") => "/".into(),
+ (_, "/") => uri_prefix.trim_end_matches('/').into(),
+ _ => format!("{}{}", uri_prefix, path.trim_matches('/')),
+ };
+ encode_uri(&new_path)
}
fn walk_path(path: &str) -> impl Iterator<Item = &str> {
assert_eq!(resp.status(), 403);
Ok(())
}
+
+#[rstest]
+fn auth_path_prefix(
+ #[with(&["--auth", "/@user:pass", "--path-prefix", "xyz", "-A"])] server: TestServer,
+) -> Result<(), Error> {
+ let url = format!("{}xyz/index.html", server.url());
+ let resp = fetch!(b"GET", &url).send()?;
+ assert_eq!(resp.status(), 401);
+ let resp = fetch!(b"GET", &url).send_with_digest_auth("user", "pass")?;
+ assert_eq!(resp.status(), 200);
+ Ok(())
+}