diff --git a/backend/src/check/check.service.ts b/backend/src/check/check.service.ts index 5fd6a0f0..8306887d 100644 --- a/backend/src/check/check.service.ts +++ b/backend/src/check/check.service.ts @@ -1,12 +1,11 @@ import { Injectable } from "@nestjs/common"; +import { JwtService } from "@nestjs/jwt"; +import * as moment from "moment"; import { PrismaService } from "src/db/prisma.service"; -import { CheckNameConflicReponse } from "./types/check-name-conflict-response.type"; -import slugify from "slugify"; +import { JwtPayload } from "src/utils/types/jwt.type"; import { CheckYorkieDto, YorkieMethod } from "./dto/check-yorkie.dto"; +import { CheckNameConflicReponse } from "./types/check-name-conflict-response.type"; import { CheckYorkieResponse } from "./types/check-yorkie-response.type"; -import { JwtService } from "@nestjs/jwt"; -import { JwtPayload } from "src/utils/types/jwt.type"; -import * as moment from "moment"; @Injectable() export class CheckService { @@ -16,15 +15,15 @@ export class CheckService { ) {} async checkNameConflict(name: string): Promise { - const slug = slugify(name, { lower: true }); + const encodedText = encodeURIComponent(name); const conflictUserList = await this.prismaService.user.findMany({ where: { - OR: [{ nickname: name }, { nickname: slug }], + OR: [{ nickname: name }, { nickname: encodedText }], }, }); const conflictWorkspaceList = await this.prismaService.workspace.findMany({ where: { - OR: [{ title: name }, { title: slug }], + OR: [{ title: name }, { title: encodedText }], }, }); diff --git a/backend/src/users/users.service.ts b/backend/src/users/users.service.ts index 04de8452..c7d58a21 100644 --- a/backend/src/users/users.service.ts +++ b/backend/src/users/users.service.ts @@ -1,10 +1,9 @@ import { ConflictException, Injectable } from "@nestjs/common"; import { User } from "@prisma/client"; -import { PrismaService } from "src/db/prisma.service"; -import { FindUserResponse } from "./types/find-user-response.type"; import { CheckService } from "src/check/check.service"; -import slugify from "slugify"; +import { PrismaService } from "src/db/prisma.service"; import { WorkspaceRoleConstants } from "src/utils/constants/auth-role"; +import { FindUserResponse } from "./types/find-user-response.type"; @Injectable() export class UsersService { @@ -95,7 +94,7 @@ export class UsersService { }, }); - const slug = slugify(nickname, { lower: true }); + const encodedText = encodeURIComponent(nickname); if (!userWorkspaceList.length) { const { id: workspaceId } = await this.prismaService.workspace.create({ @@ -104,7 +103,7 @@ export class UsersService { }, data: { title: nickname, - slug, + slug: encodedText, }, }); diff --git a/backend/src/workspaces/workspaces.service.ts b/backend/src/workspaces/workspaces.service.ts index 978f66d0..aca25e8f 100644 --- a/backend/src/workspaces/workspaces.service.ts +++ b/backend/src/workspaces/workspaces.service.ts @@ -5,14 +5,13 @@ import { UnauthorizedException, } from "@nestjs/common"; import { Prisma, Workspace } from "@prisma/client"; +import * as moment from "moment"; +import { CheckService } from "src/check/check.service"; import { PrismaService } from "src/db/prisma.service"; -import { FindWorkspacesResponse } from "./types/find-workspaces-response.type"; -import { CreateInvitationTokenResponse } from "./types/create-inviation-token-response.type"; import { WorkspaceRoleConstants } from "src/utils/constants/auth-role"; -import slugify from "slugify"; import { generateRandomKey } from "src/utils/functions/random-string"; -import * as moment from "moment"; -import { CheckService } from "src/check/check.service"; +import { CreateInvitationTokenResponse } from "./types/create-inviation-token-response.type"; +import { FindWorkspacesResponse } from "./types/find-workspaces-response.type"; @Injectable() export class WorkspacesService { @@ -31,7 +30,7 @@ export class WorkspacesService { const workspace = await this.prismaService.workspace.create({ data: { title, - slug: slugify(title, { lower: true }), + slug: encodeURIComponent(title), }, });