Skip to content

Commit

Permalink
Stricter repository field validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlancollins committed Nov 12, 2023
1 parent 9c5242a commit 5d4c9f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/lib/schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ export const componentsSchema = z.array(
title: z.string(),
npm: z.string().regex(/^(@[a-z0-9-]*\/)?[a-z0-9-]*$/),
url: z.string().url().optional(),
repository: z.string().url(),
repository: z
.string()
.url()
.refine((val) => val.includes('github.com') || val.includes('gitlab.com')),
description: z.string(),
category: z.enum([
'Display Components',
Expand Down Expand Up @@ -33,7 +36,10 @@ export const templatesSchema = z.array(
z.object({
title: z.string(),
url: z.string().url().optional(),
repository: z.string().url(),
repository: z
.string()
.url()
.refine((val) => val.includes('github.com') || val.includes('gitlab.com')),
description: z.string(),
category: z.enum(['Svelte Add', 'SvelteKit', 'Svelte']),
tags: z.array(z.string()).optional()
Expand All @@ -48,7 +54,10 @@ export const toolsSchema = z.array(
.regex(/^(@[a-z0-9-]*\/)?[a-z0-9-]*$/)
.optional(),
url: z.string().url().optional(),
repository: z.string().url(),
repository: z
.string()
.url()
.refine((val) => val.includes('github.com') || val.includes('gitlab.com')),
description: z.string(),
category: z.enum([
'Debugging',
Expand Down
3 changes: 2 additions & 1 deletion src/routes/components/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@
},
{
"title": "SCR Svelte Client Router",
"repository": "https://arthurgermano.github.io/svelte-client-router/#/svelte-client-router",
"url": "https://arthurgermano.github.io/svelte-client-router/#/svelte-client-router",
"repository": "https://github.com/arthurgermano/svelte-client-router",
"npm": "svelte-client-router",
"description": "Svelte Client Router is everything you need and think when routing SPA's. This is The Svelte Router for SPA!",
"tags": ["routers"],
Expand Down

0 comments on commit 5d4c9f3

Please sign in to comment.