Skip to content

Commit

Permalink
feat: support search in quay
Browse files Browse the repository at this point in the history
  • Loading branch information
snowdream committed Oct 14, 2024
1 parent 5a68489 commit 34a3d01
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ addEventListener("fetch", (event) => {

const registry_dockerHub = "https://registry-1.docker.io";
const index_dockerHub = "https://index.docker.io";
const registry_quay = "https://quay.io";
const index_quay = "https://quay.io";

const routes = {
// production
Expand Down Expand Up @@ -56,10 +58,20 @@ async function handleRequest(request) {
});
}
const isDockerHub = upstream == registry_dockerHub;
const isQuay = upstream == registry_quay;
const authorization = request.headers.get("Authorization");

if (url.pathname == "/v1/search" && isDockerHub) {
const newUrl = new URL(index_dockerHub + "/v1/search");
if (url.pathname == "/v1/search") {
let newUrl = url

if(isDockerHub){
newUrl = new URL(index_dockerHub + "/v1/search");
}else if(isQuay){
newUrl = new URL(index_quay + "/v1/search");
}else{
newUrl = url
}

newUrl.search = url.search;

const headers = new Headers();
Expand Down

0 comments on commit 34a3d01

Please sign in to comment.