diff --git a/__test__/common/github/RepoRestrictedGitHubClient.test.ts b/__test__/common/github/RepoRestrictedGitHubClient.test.ts index 852e6754..134968c0 100644 --- a/__test__/common/github/RepoRestrictedGitHubClient.test.ts +++ b/__test__/common/github/RepoRestrictedGitHubClient.test.ts @@ -7,7 +7,6 @@ import { GetRepositoryContentRequest, GraphQLQueryRequest, UpdatePullRequestCommentRequest, - GitHubClient } from "@/common"; import { jest } from '@jest/globals'; @@ -37,7 +36,7 @@ describe('RepoRestrictedGitHubClient', () => { expect(gitHubClient.graphql).toHaveBeenCalledWith(request); }); - it('should check suffix for getRepositoryContent', async () => { + it('should delegate getRepositoryContent to the underlying client', async () => { const request: GetRepositoryContentRequest = { repositoryName: 'repo-suffix', path: '', repositoryOwner: '', @@ -56,7 +55,7 @@ describe('RepoRestrictedGitHubClient', () => { await expect(client.getRepositoryContent(request)).rejects.toThrow("Invalid repository name"); }); - it('should check suffix for getPullRequestFiles', async () => { + it('should delegate getPullRequestFiles to the underlying client', async () => { const request: GetPullRequestFilesRequest = { repositoryName: 'repo-suffix', pullRequestNumber: 1, appInstallationId: 0, @@ -75,7 +74,7 @@ describe('RepoRestrictedGitHubClient', () => { await expect(client.getPullRequestFiles(request)).rejects.toThrow("Invalid repository name"); }); - it('should check suffix for getPullRequestComments', async () => { + it('should delegate getPullRequestComments to the underlying client', async () => { const request: GetPullRequestCommentsRequest = { repositoryName: 'repo-suffix', pullRequestNumber: 1, appInstallationId: 0, @@ -94,7 +93,7 @@ describe('RepoRestrictedGitHubClient', () => { await expect(client.getPullRequestComments(request)).rejects.toThrow("Invalid repository name"); }); - it('should check suffix for addCommentToPullRequest', async () => { + it('should delegate addCommentToPullRequest to the underlying client', async () => { const request: AddCommentToPullRequestRequest = { repositoryName: 'repo-suffix', pullRequestNumber: 1, body: '', appInstallationId: 0, @@ -113,7 +112,7 @@ describe('RepoRestrictedGitHubClient', () => { await expect(client.addCommentToPullRequest(request)).rejects.toThrow("Invalid repository name"); }); - it('should check suffix for updatePullRequestComment', async () => { + it('should delegate updatePullRequestComment to the underlying client', async () => { const request: UpdatePullRequestCommentRequest = { repositoryName: 'repo-suffix', commentId: 1, body: '', appInstallationId: 0, diff --git a/src/app/api/blob/[owner]/[repository]/[...path]/route.ts b/src/app/api/blob/[owner]/[repository]/[...path]/route.ts index ad91bf3d..cf7e43a0 100644 --- a/src/app/api/blob/[owner]/[repository]/[...path]/route.ts +++ b/src/app/api/blob/[owner]/[repository]/[...path]/route.ts @@ -28,6 +28,8 @@ export async function GET(req: NextRequest, { params }: { params: GetBlobParams const cacheExpirationInSeconds = 60 * 60 * 24 * 30 // 30 days headers.set("Content-Type", "image/*"); headers.set("Cache-Control", `max-age=${cacheExpirationInSeconds}`) + } else { + headers.set("Content-Type", "text/plain"); } return new NextResponse(file, { status: 200, headers }) } diff --git a/src/app/api/proxy/route.ts b/src/app/api/proxy/route.ts index 4a6c4b9a..5d5f10b4 100644 --- a/src/app/api/proxy/route.ts +++ b/src/app/api/proxy/route.ts @@ -30,7 +30,7 @@ export async function GET(req: NextRequest) { const maxBytes = maxMegabytes * 1024 * 1024 const fileText = await downloadFile({ url, maxBytes, timeoutInSeconds }) checkIfJsonOrYaml(fileText) - return new NextResponse(fileText, { status: 200 }) + return new NextResponse(fileText, { status: 200, headers: { "Content-Type": "text/plain" } }) } catch (error) { if (error instanceof Error == false) { return makeAPIErrorResponse(500, "An unknown error occurred.")