Skip to content

Commit 34a3d01

Browse files
committed
feat: support search in quay
1 parent 5a68489 commit 34a3d01

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ addEventListener("fetch", (event) => {
77

88
const registry_dockerHub = "https://registry-1.docker.io";
99
const index_dockerHub = "https://index.docker.io";
10+
const registry_quay = "https://quay.io";
11+
const index_quay = "https://quay.io";
1012

1113
const routes = {
1214
// production
@@ -56,10 +58,20 @@ async function handleRequest(request) {
5658
});
5759
}
5860
const isDockerHub = upstream == registry_dockerHub;
61+
const isQuay = upstream == registry_quay;
5962
const authorization = request.headers.get("Authorization");
6063

61-
if (url.pathname == "/v1/search" && isDockerHub) {
62-
const newUrl = new URL(index_dockerHub + "/v1/search");
64+
if (url.pathname == "/v1/search") {
65+
let newUrl = url
66+
67+
if(isDockerHub){
68+
newUrl = new URL(index_dockerHub + "/v1/search");
69+
}else if(isQuay){
70+
newUrl = new URL(index_quay + "/v1/search");
71+
}else{
72+
newUrl = url
73+
}
74+
6375
newUrl.search = url.search;
6476

6577
const headers = new Headers();

0 commit comments

Comments
 (0)