Improve Docker registry path validation
Updates Docker request handling to allow both /cr/ and /v2/cr/ prefixes, and clarifies path normalization for Docker registry API consistency.
This commit is contained in:
1 parent
3e3eab5867
commit
7355cd3fce
1 file changed
+4
-3
+4
-3
@@ -242,14 +242,15 @@ async function handleRequest(request, env, ctx) {
|
||||
|
||||
// Handle Docker registry paths specially
|
||||
if (isDocker) {
|
||||
// For Docker, path should start with /cr/ prefix
|
||||
if (!url.pathname.startsWith('/cr/')) {
|
||||
// For Docker requests (excluding version check which is handled above),
|
||||
// check if they have /cr/ prefix
|
||||
if (!url.pathname.startsWith('/cr/') && !url.pathname.startsWith('/v2/cr/')) {
|
||||
return new Response('Docker registry requests must use /cr/ prefix', {
|
||||
status: 400,
|
||||
headers: addSecurityHeaders(new Headers())
|
||||
});
|
||||
}
|
||||
// Remove /v2 from the path for Docker registry API consistency
|
||||
// Remove /v2 from the path for Docker registry API consistency if present
|
||||
effectivePath = url.pathname.replace(/^\/v2/, '');
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user