From f2d90b3dcdb8f509c892c58af65b07871912125b Mon Sep 17 00:00:00 2001 From: Sonny Date: Sun, 8 May 2022 22:49:31 +0200 Subject: [PATCH] update db col max size + add char to url regex --- .../20220508204826_update_col_max_size/migration.sql | 6 ++++++ prisma/schema.prisma | 6 +++--- utils/front.ts | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 prisma/migrations/20220508204826_update_col_max_size/migration.sql diff --git a/prisma/migrations/20220508204826_update_col_max_size/migration.sql b/prisma/migrations/20220508204826_update_col_max_size/migration.sql new file mode 100644 index 0000000..acc8262 --- /dev/null +++ b/prisma/migrations/20220508204826_update_col_max_size/migration.sql @@ -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; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 881617f..e6c2b0f 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -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) diff --git a/utils/front.ts b/utils/front.ts index 15c48a1..00f6e9c 100644 --- a/utils/front.ts +++ b/utils/front.ts @@ -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; }