update db col max size + add char to url regex

This commit is contained in:
Sonny
2022-05-08 22:49:31 +02:00
parent e914da7f2b
commit f2d90b3dcd
3 changed files with 10 additions and 4 deletions

View File

@@ -0,0 +1,6 @@
-- AlterTable
ALTER TABLE `category` MODIFY `name` VARCHAR(255) NOT NULL;
-- AlterTable
ALTER TABLE `link` MODIFY `name` VARCHAR(255) NOT NULL,
MODIFY `url` TEXT NOT NULL;

View File

@@ -20,7 +20,7 @@ model User {
model Category {
id Int @id @default(autoincrement())
name String @unique
name String @unique @db.VarChar(255)
links Link[]
nextCategoryId Int @default(0)
createdAt DateTime @default(now())
@@ -29,8 +29,8 @@ model Category {
model Link {
id Int @id @default(autoincrement())
name String
url String
name String @db.VarChar(255)
url String @db.Text
category Category @relation(fields: [categoryId], references: [id])
categoryId Int
nextLinkId Int @default(0)

View File

@@ -29,7 +29,7 @@ export function BuildLink({ id, name, url, nextLinkId, favorite, createdAt, upda
}
export function IsValidURL(url: string): boolean {
const regex = new RegExp(/^(?:http(s)?:\/\/)[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/);
const regex = new RegExp(/^(?:http(s)?:\/\/)[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.\%]+$/);
return url.match(regex) ? true : false;
}