diff --git a/src/app/components/dialog/CreateMirrorDialog.tsx b/src/app/components/dialog/CreateMirrorDialog.tsx index 779105d..9238ba8 100644 --- a/src/app/components/dialog/CreateMirrorDialog.tsx +++ b/src/app/components/dialog/CreateMirrorDialog.tsx @@ -63,6 +63,7 @@ export const CreateMirrorDialog = ({ onChange={(e) => setRepoName(e.target.value)} block placeholder="e.g. repository-name" + maxLength={100} /> This is a private mirror of{' '} diff --git a/src/app/components/dialog/EditMirrorDialog.tsx b/src/app/components/dialog/EditMirrorDialog.tsx index e0b30da..8b76dd7 100644 --- a/src/app/components/dialog/EditMirrorDialog.tsx +++ b/src/app/components/dialog/EditMirrorDialog.tsx @@ -75,6 +75,7 @@ export const EditMirrorDialog = ({ onChange={(e) => setNewMirrorName(e.target.value)} block placeholder="e.g. repository-name" + maxLength={100} /> This is a private mirror of{' '} diff --git a/src/server/repos/schema.ts b/src/server/repos/schema.ts index 6f20814..5f74f59 100644 --- a/src/server/repos/schema.ts +++ b/src/server/repos/schema.ts @@ -5,7 +5,7 @@ export const CreateMirrorSchema = z.object({ forkRepoOwner: z.string(), forkRepoName: z.string(), forkId: z.string(), - newRepoName: z.string(), + newRepoName: z.string().max(100), newBranchName: z.string(), }) @@ -17,7 +17,7 @@ export const ListMirrorsSchema = z.object({ export const EditMirrorSchema = z.object({ orgId: z.string(), mirrorName: z.string(), - newMirrorName: z.string(), + newMirrorName: z.string().max(100), }) export const DeleteMirrorSchema = z.object({ diff --git a/test/server/repos.test.ts b/test/server/repos.test.ts index 1491c19..58db84b 100644 --- a/test/server/repos.test.ts +++ b/test/server/repos.test.ts @@ -263,4 +263,23 @@ describe('Repos router', () => { }) expect(stubbedGit.clone).toHaveBeenCalledTimes(1) }) + + it('reject repository names over the character limit', async () => { + const caller = reposRouter.createCaller(createTestContext()) + + await caller + .createMirror({ + forkId: 'test', + orgId: 'test', + forkRepoName: 'fork-test', + forkRepoOwner: 'github', + newBranchName: 'test', + newRepoName: 'a'.repeat(101), + }) + .catch((error) => { + expect(error.message).toMatch( + /String must contain at most 100 character\(s\)/, + ) + }) + }) })