From 7168f37d705b5ab16b311e45b4bfa6bf47ae84b1 Mon Sep 17 00:00:00 2001 From: FilipeR13 Date: Sun, 30 Mar 2025 12:55:29 +0100 Subject: [PATCH 1/2] feat: allowed multiple links --- src/pages/api/projects/create.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/pages/api/projects/create.ts b/src/pages/api/projects/create.ts index c4094fcd..aa52b121 100644 --- a/src/pages/api/projects/create.ts +++ b/src/pages/api/projects/create.ts @@ -11,7 +11,7 @@ const supabase = createClient( const apiGithub = "https://api.github.com/repos/"; // TODO: Change this date to the contest start date -const beginContestDate = new Date("2025-03-28T18:00:00Z"); +const beginContestDate = new Date("2000-03-28T18:00:00Z"); export const POST: APIRoute = async ({ request }) => { const formData = await request.formData(); @@ -98,6 +98,22 @@ const validateTeamCode = async (team_code: string, errors: String[]) => { } const validateLink = async (link: string, errors: String[]) => { + const links = link.split(" "); + + for (let i = 0; i < links.length; i++) { + const link = links[i].trim(); + if (link.length > 0) { + const valid = await validateGithubLink(link, errors); + if (!valid) { + return false; + } + } + } + + return true; +} + +const validateGithubLink = async (link: string, errors: String[]) => { const githubLinkRegex = /^https:\/\/github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)$/; const match = link.match(githubLinkRegex); From 0caca668b00d4d1b6f4b3d280e73903bfaef9221 Mon Sep 17 00:00:00 2001 From: FilipeR13 Date: Sun, 30 Mar 2025 12:56:25 +0100 Subject: [PATCH 2/2] fix: date --- src/pages/api/projects/create.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/api/projects/create.ts b/src/pages/api/projects/create.ts index aa52b121..08249b93 100644 --- a/src/pages/api/projects/create.ts +++ b/src/pages/api/projects/create.ts @@ -11,7 +11,7 @@ const supabase = createClient( const apiGithub = "https://api.github.com/repos/"; // TODO: Change this date to the contest start date -const beginContestDate = new Date("2000-03-28T18:00:00Z"); +const beginContestDate = new Date("2025-03-28T18:00:00Z"); export const POST: APIRoute = async ({ request }) => { const formData = await request.formData();