Openstatus www.openstatus.dev
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: uppercase slug to lowercase (#166)

authored by

Maximilian Kaske and committed by
GitHub
c2bdf1ea 221c90da

+10 -6
+4 -1
apps/web/src/components/forms/status-page-form.tsx
··· 63 63 const isUnique = await api.page.getSlugUniqueness.query({ 64 64 slug: debouncedSlug, 65 65 }); 66 - return isUnique || debouncedSlug === defaultValues?.slug; 66 + return ( 67 + isUnique || 68 + debouncedSlug.toLowerCase() === defaultValues?.slug.toLowerCase() 69 + ); 67 70 }, [debouncedSlug, defaultValues?.slug]); 68 71 69 72 React.useEffect(() => {
+5 -5
packages/api/src/router/page.ts
··· 2 2 import { z } from "zod"; 3 3 4 4 import { analytics, trackAnalytics } from "@openstatus/analytics"; 5 - import { and, eq, inArray } from "@openstatus/db"; 5 + import { and, eq, inArray, sql } from "@openstatus/db"; 6 6 import { 7 7 insertPageSchemaWithMonitors, 8 8 monitor, ··· 232 232 233 233 // public if we use trpc hooks to get the page from the url 234 234 getPageBySlug: publicProcedure 235 - .input(z.object({ slug: z.string() })) 235 + .input(z.object({ slug: z.string().toLowerCase() })) 236 236 .query(async (opts) => { 237 237 const result = await opts.ctx.db.query.page.findFirst({ 238 - where: eq(page.slug, opts.input.slug), 238 + where: sql`lower(${page.slug}) = ${opts.input.slug}`, 239 239 with: { incidents: true }, 240 240 }); 241 241 ··· 273 273 }), 274 274 275 275 getSlugUniqueness: protectedProcedure 276 - .input(z.object({ slug: z.string() })) 276 + .input(z.object({ slug: z.string().toLowerCase() })) 277 277 .query(async (opts) => { 278 278 // had filter on some words we want to keep for us 279 279 if (["api", "app", "www", "docs"].includes(opts.input.slug)) { 280 280 return false; 281 281 } 282 282 const result = await opts.ctx.db.query.page.findMany({ 283 - where: eq(page.slug, opts.input.slug), 283 + where: sql`lower(${page.slug}) = ${opts.input.slug}`, 284 284 }); 285 285 return result?.length > 0 ? false : true; 286 286 }),
+1
packages/db/src/schema/page.ts
··· 54 54 customDomain: z.string().optional().default(""), 55 55 monitors: z.array(z.number()).optional(), 56 56 workspaceSlug: z.string().optional(), 57 + slug: z.string().toLowerCase(), 57 58 }); 58 59 // Schema for selecting a Page - can be used to validate API responses 59 60 export const selectPageSchema = createSelectSchema(page);