diff --git a/src/constants/r2Prefixes.ts b/src/constants/r2Prefixes.ts index 4d4fd4d..f429f10 100644 --- a/src/constants/r2Prefixes.ts +++ b/src/constants/r2Prefixes.ts @@ -34,5 +34,4 @@ export const URL_TO_BUCKET_PATH_MAP: Record string> = DOCS_PATH_PREFIX + (path.substring('/docs'.length) || '/'), api: (path): string => API_PATH_PREFIX + (path.substring('/api'.length) || '/'), - metrics: (path): string => path.substring(1), // substring to cut off the / }; diff --git a/src/utils/path.ts b/src/utils/path.ts index 6c9e348..69f453c 100644 --- a/src/utils/path.ts +++ b/src/utils/path.ts @@ -147,9 +147,6 @@ export function mapBucketPathToUrlPath( } else if (bucketPath.startsWith(DOWNLOAD_PATH_PREFIX)) { // Rest of the `/download/...` paths (e.g. `/download/nightly/`) return [`/download${bucketPath.substring(DOWNLOAD_PATH_PREFIX.length)}`]; - } else if (bucketPath.startsWith('metrics')) { - // Metrics doesn't need any redirects - return ['/' + bucketPath]; } return env.DIRECTORY_LISTING === 'restricted' diff --git a/tests/e2e/directory.test.ts b/tests/e2e/directory.test.ts index 6d07794..51b051c 100644 --- a/tests/e2e/directory.test.ts +++ b/tests/e2e/directory.test.ts @@ -24,9 +24,8 @@ async function startS3Mock(): Promise { const r2Prefix = url.searchParams.get('prefix')!; let doesFolderExist = - ['nodejs/release/', 'nodejs/', 'nodejs/docs/', 'metrics/'].includes( - r2Prefix - ) || r2Prefix.endsWith('/docs/api/'); + ['nodejs/release/', 'nodejs/', 'nodejs/docs/'].includes(r2Prefix) || + r2Prefix.endsWith('/docs/api/'); if (doesFolderExist) { xmlFilePath += 'ListObjectsV2-exists.xml'; @@ -143,20 +142,6 @@ describe('Directory Tests (Restricted Directory Listing)', () => { assert.strictEqual(res.status, 200); }); - it('redirects `/metrics` to `/metrics/`', async () => { - const originalRes = await mf.dispatchFetch(`${url}metrics`, { - redirect: 'manual', - }); - assert.strictEqual(originalRes.status, 301); - const res = await mf.dispatchFetch(originalRes.headers.get('location')!); - assert.strictEqual(res.status, 200); - }); - - it('allows `/metrics/`', async () => { - const res = await mf.dispatchFetch(`${url}metrics/`); - assert.strictEqual(res.status, 200); - }); - it('returns 401 for unrecognized base paths', async () => { let res = await mf.dispatchFetch(url); assert.strictEqual(res.status, 401);