File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 11export const slugify = ( str : string ) => {
2- return str . replace ( / \s + / g, "-" ) . toLowerCase ( ) ;
2+ return str . replace ( / [ ^ a - z A - Z 0 - 9 - ] / g, "-" ) . toLowerCase ( ) ;
33} ;
44
55export default slugify ;
Original file line number Diff line number Diff line change 1- import prisma from "../../../lib/prisma" ;
2- import { hashPassword } from "../../../lib/auth" ;
1+ import { hashPassword } from "@lib/auth" ;
2+ import prisma from "@lib/prisma" ;
3+ import slugify from "@lib/slugify" ;
4+ import { NextApiRequest , NextApiResponse } from "next" ;
35
4- export default async function handler ( req , res ) {
6+ export default async function handler ( req : NextApiRequest , res : NextApiResponse ) {
57 if ( req . method !== "POST" ) {
68 return ;
79 }
810
911 const data = req . body ;
10- const { username, email, password } = data ;
12+ const { email, password } = data ;
13+ const username = slugify ( data . username ) ;
1114
1215 if ( ! username ) {
1316 res . status ( 422 ) . json ( { message : "Invalid username" } ) ;
You can’t perform that action at this time.
0 commit comments