Skip to content

Commit bb045ee

Browse files
Remove catch-all redirect for UI (#1540)
Co-authored-by: Louis-Marie Givel <louis-marie.givel@accenture.com>
1 parent e063e58 commit bb045ee

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

josh-proxy/src/bin/josh-proxy.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,19 +1253,17 @@ async fn call_service(
12531253
}
12541254
pu
12551255
} else {
1256-
let redirect_path = if path == "/" {
1257-
"/~/ui/".to_string()
1256+
if path == "/" {
1257+
let redirect_path = "/~/ui/".to_string();
1258+
return Ok(Response::builder()
1259+
.status(hyper::StatusCode::FOUND)
1260+
.header("Location", redirect_path)
1261+
.body(empty())?);
12581262
} else {
1259-
format!(
1260-
"/~/ui/browse?repo={}.git&path=&filter=%3A%2F&rev=HEAD",
1261-
path
1262-
)
1263+
return Ok(Response::builder()
1264+
.status(hyper::StatusCode::NOT_FOUND)
1265+
.body(empty())?);
12631266
};
1264-
1265-
return Ok(Response::builder()
1266-
.status(hyper::StatusCode::FOUND)
1267-
.header("Location", redirect_path)
1268-
.body(empty())?);
12691267
}
12701268
};
12711269

tests/proxy/clone_invalid_url.t

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
$ cd ${TESTTMP}
2525

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

3230
$ bash ${TESTDIR}/destroy_test_env.sh

tests/proxy/ui.t

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
date: * (glob)
2525
\r (esc)
2626
$ curl -s -I http://127.0.0.1:8002/a/repo
27-
HTTP/1.1 302 Found\r (esc)
28-
location: /~/ui/browse?repo=/a/repo.git&path=&filter=%3A%2F&rev=HEAD\r (esc)
27+
HTTP/1.1 404 Not Found\r (esc)
2928
date: * (glob)
3029
\r (esc)

0 commit comments

Comments
 (0)