support docker official images: more routes

This commit is contained in:
Singee 2023-06-29 15:47:25 +08:00
parent 554ee35d6b
commit 6aecea168c
No known key found for this signature in database
GPG Key ID: 4EC3FD10E03041D7

View File

@ -3,6 +3,8 @@ import { Backend } from './backend'
const PROXY_HEADER_ALLOW_LIST: string[] = ["accept", "user-agent", "accept-encoding"]
const validActionNames = new Set(["manifests", "blobs", "tags", "referrers"])
// const ORG_NAME_BACKEND:{ [key: string]: string; } = {
// "gcr": "https://gcr.io",
// "k8sgcr": "https://k8s.gcr.io",
@ -45,7 +47,7 @@ function rewritePath(orgName: string | null, pathname: string): string {
// /v2/repo/manifests/xxx -> /v2/library/repo/manifests/xxx
// /v2/repo/blobs/xxx -> /v2/library/repo/blobs/xxx
if (orgName === null && splitedPath.length === 5 && (splitedPath[3] === "manifests" || splitedPath[3] === "blobs")) {
if (orgName === null && splitedPath.length === 5 && validActionNames.has(splitedPath[3])) {
splitedPath = [splitedPath[0], splitedPath[1], "library", splitedPath[2], splitedPath[3], splitedPath[4]]
}