style(proxy): format docker protocol tests

This commit is contained in:
xixu-me committed 2026-03-06 20:30:35 +08:00
1 parent cb44ddb66c
commit 213e04de76
2 files changed
+5 -8

No files matched your search

+4 -5
View File
@@ -130,7 +130,9 @@ function normalizeRepoPath(platformKey, repoPath) {
* @returns {string} Repository path without the `/v2/` prefix or operation suffix.
*/
function extractRepositoryPath(apiPath) {
const normalizedPath = apiPath.startsWith('/v2/') ? apiPath.slice(4) : apiPath.replace(/^\/+/, '');
const normalizedPath = apiPath.startsWith('/v2/')
? apiPath.slice(4)
: apiPath.replace(/^\/+/, '');
const pathParts = normalizedPath.split('/').filter(Boolean);
if (pathParts.length === 0 || pathParts[0].startsWith('_')) {
@@ -228,10 +230,7 @@ export function responseUnauthorized(url, platform) {
const realmPath = platform ? `/cr/${platform.slice(3)}/v2/auth` : '/v2/auth';
const headers = new Headers();
headers.set('Content-Type', 'application/json');
headers.set(
'WWW-Authenticate',
`Bearer realm="${url.origin}${realmPath}",service="Xget"`
);
headers.set('WWW-Authenticate', `Bearer realm="${url.origin}${realmPath}",service="Xget"`);
return new Response(
JSON.stringify({
errors: [
+1 -3
View File
@@ -198,9 +198,7 @@ describe('Docker Authentication', () => {
const response = await worker.fetch(request, {}, executionContext);
expect(response.status).toBe(200);
expect(String(fetchSpy.mock.calls[1][0])).toContain(
'scope=repository%3Aprivate%2Frepo%3Apull'
);
expect(String(fetchSpy.mock.calls[1][0])).toContain('scope=repository%3Aprivate%2Frepo%3Apull');
});
});