Skip to content

Commit dd00934

Browse files
feat: reserved vanity
1 parent ba55763 commit dd00934

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

utils/Regex.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import urlRegex from 'url-regex-safe'
2+
const reservedVanityConst = [ 'koreanbots', 'koreanservers', 'koreanlist', 'kbots', 'kodl', 'discord' ]
23

34
export const ID = /^[0-9]{17,}$/
45
export const Vanity = /^[A-Za-z\d-]+$/
@@ -12,3 +13,4 @@ export const Heading = '<h\\d id="(.+?)">(.*?)<\\/h(\\d)>'
1213
export const EmojiSyntax = ':(\\w+):'
1314
export const ImageTag = /<img\s[^>]*?alt\s*=\s*['"]([^'"]*?)['"][^>]*?>/
1415
export const markdownImage = /!\[([^\]]*)\]\((.*?)\s*("(?:.*[^"])")?\s*\)/g
16+
export const reservedVanity = new RegExp(`^((?!${reservedVanityConst.join('|')}).)*$`, 'i') // 예약되지 않음을 확인

utils/Yup.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as Yup from 'yup'
22
import YupKorean from 'yup-locales-ko'
33
import { ListType } from '@types'
44
import { botCategories, library, reportCats, serverCategories } from '@utils/Constants'
5-
import { HTTPProtocol, ID, Prefix, Url, Vanity } from '@utils/Regex'
5+
import { HTTPProtocol, ID, Prefix, reservedVanity, Url, Vanity } from '@utils/Regex'
66

77
Yup.setLocale(YupKorean)
88
Yup.addMethod(Yup.array, 'unique', function (message, mapper = (a) => a) {
@@ -296,10 +296,11 @@ export const ManageBotSchema: Yup.SchemaOf<ManageBot> = Yup.object({
296296
.min(100, '봇 설명은 최소 100자여야합니다.')
297297
.max(1500, '봇 설명은 최대 1500자여야합니다.')
298298
.required('봇 설명은 필수 항목입니다.'),
299-
vanity: Yup.string()
299+
vanity: Yup.string()
300300
.min(3, '커스텀 URL은 최소 3자여야합니다.')
301301
.max(32, '커스텀 URL은 최대 32자여야합니다.')
302302
.matches(Vanity, '커스텀 URL은 영문만 포함할 수 있습니다.')
303+
.matches(reservedVanity, '사용할 수 없는 커스텀 URL입니다.')
303304
.nullable(),
304305
banner: Yup.string()
305306
.matches(HTTPProtocol, 'http:// 또는 https:// 로 시작해야합니다.')

0 commit comments

Comments
 (0)