Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions josh-proxy/src/bin/josh-proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,19 +1253,17 @@ async fn call_service(
}
pu
} else {
let redirect_path = if path == "/" {
"/~/ui/".to_string()
if path == "/" {
let redirect_path = "/~/ui/".to_string();
return Ok(Response::builder()
.status(hyper::StatusCode::FOUND)
.header("Location", redirect_path)
.body(empty())?);
} else {
format!(
"/~/ui/browse?repo={}.git&path=&filter=%3A%2F&rev=HEAD",
path
)
return Ok(Response::builder()
.status(hyper::StatusCode::NOT_FOUND)
.body(empty())?);
};

return Ok(Response::builder()
.status(hyper::StatusCode::FOUND)
.header("Location", redirect_path)
.body(empty())?);
}
};

Expand Down
4 changes: 1 addition & 3 deletions tests/proxy/clone_invalid_url.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
$ cd ${TESTTMP}

$ git clone -q http://localhost:8002/xxx full_repo
fatal: unable to update url base from redirection:
asked for: http://localhost:8002/xxx/info/refs?service=git-upload-pack
redirect: http://localhost:8002/~/ui/browse?repo=/xxx/info/refs.git&path=&filter=%3A%2F&rev=HEAD
fatal: repository 'http://localhost:8002/xxx/' not found
[128]

$ bash ${TESTDIR}/destroy_test_env.sh
Expand Down
3 changes: 1 addition & 2 deletions tests/proxy/ui.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
date: * (glob)
\r (esc)
$ curl -s -I http://127.0.0.1:8002/a/repo
HTTP/1.1 302 Found\r (esc)
location: /~/ui/browse?repo=/a/repo.git&path=&filter=%3A%2F&rev=HEAD\r (esc)
HTTP/1.1 404 Not Found\r (esc)
date: * (glob)
\r (esc)