Skip to content

Remove /metrics redirects #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/constants/r2Prefixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ export const URL_TO_BUCKET_PATH_MAP: Record<string, (path: string) => 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 /
};
3 changes: 0 additions & 3 deletions src/utils/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
19 changes: 2 additions & 17 deletions tests/e2e/directory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ async function startS3Mock(): Promise<http.Server> {
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';
Expand Down Expand Up @@ -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);
Expand Down
Loading