Skip to content
Merged
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
11 changes: 5 additions & 6 deletions __test__/common/github/RepoRestrictedGitHubClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
GetRepositoryContentRequest,
GraphQLQueryRequest,
UpdatePullRequestCommentRequest,
GitHubClient
} from "@/common";
import { jest } from '@jest/globals';

Expand Down Expand Up @@ -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: '',
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/app/api/blob/[owner]/[repository]/[...path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
2 changes: 1 addition & 1 deletion src/app/api/proxy/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down