From 554ee35d6b556faecb1c0055c400061d8bd15aaf Mon Sep 17 00:00:00 2001 From: Singee Date: Thu, 29 Jun 2023 15:33:58 +0800 Subject: [PATCH] support docker official images --- src/handler.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/handler.ts b/src/handler.ts index d5ebbc3..b2ad0a0 100644 --- a/src/handler.ts +++ b/src/handler.ts @@ -43,9 +43,10 @@ function hostByOrgName(orgName: string|null): string { function rewritePath(orgName: string | null, pathname: string): string { let splitedPath = pathname.split("/"); - // /v2/repo -> /v2/library/repo - if (orgName === null && splitedPath.length === 3) { - splitedPath = [splitedPath[0], splitedPath[1], "library", splitedPath[2]] + // /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")) { + splitedPath = [splitedPath[0], splitedPath[1], "library", splitedPath[2], splitedPath[3], splitedPath[4]] } return splitedPath.join("/")