Skip to content

Commit 783d22d

Browse files
Remove catch-all redirect for UI
1 parent bee495c commit 783d22d

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,19 +1259,17 @@ async fn call_service(
12591259
}
12601260
pu
12611261
} else {
1262-
let redirect_path = if path == "/" {
1263-
"/~/ui/".to_string()
1262+
if path == "/" {
1263+
let redirect_path = "/~/ui/".to_string();
1264+
return Ok(Response::builder()
1265+
.status(hyper::StatusCode::FOUND)
1266+
.header("Location", redirect_path)
1267+
.body(Full::new(Bytes::new()))?);
12641268
} else {
1265-
format!(
1266-
"/~/ui/browse?repo={}.git&path=&filter=%3A%2F&rev=HEAD",
1267-
path
1268-
)
1269+
return Ok(Response::builder()
1270+
.status(hyper::StatusCode::NOT_FOUND)
1271+
.body(Full::new(Bytes::new()))?);
12691272
};
1270-
1271-
return Ok(Response::builder()
1272-
.status(hyper::StatusCode::FOUND)
1273-
.header("Location", redirect_path)
1274-
.body(Full::new(Bytes::new()))?);
12751273
}
12761274
};
12771275

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

0 commit comments

Comments
 (0)