From 3b84d3493c5edc464ed85c1aa20fce5f7d7ad404 Mon Sep 17 00:00:00 2001 From: seaerchin <44049504+seaerchin@users.noreply.github.com> Date: Thu, 21 Mar 2024 17:28:31 +0800 Subject: [PATCH] fix(media): update routes (#1862) --- src/layouts/Media/Media.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/layouts/Media/Media.tsx b/src/layouts/Media/Media.tsx index 16db4e25d..44a4f577d 100644 --- a/src/layouts/Media/Media.tsx +++ b/src/layouts/Media/Media.tsx @@ -59,6 +59,7 @@ import { import { MediaData } from "types/directory" import { MediaFolderTypes, MediaLabels, SelectedMediaDto } from "types/media" import { + ALLOWED_CHARACTERS_REGEX, DEFAULT_RETRY_MSG, specialCharactersRegexTest, useErrorToast, @@ -732,7 +733,8 @@ export const Media = (): JSX.Element => { validate={{ fileName: (value) => { const encodedName = value.split(".").slice(0, -1).join(".") - return !specialCharactersRegexTest.test(encodedName) + const decodedName = decodeURIComponent(encodedName) + return ALLOWED_CHARACTERS_REGEX.test(decodedName) }, }} /> @@ -742,11 +744,11 @@ export const Media = (): JSX.Element => { onClose={() => history.goBack()} validate={{ mediaDirectoryName: (value) => { - // NOTE: This value is prepended with either `files|images/` + // NOTE: This value is prepended with either `files|images` // and nested directories are separated by `/` as well. const decodedValues = decodeURIComponent(value).split("/") - return decodedValues.every( - (val) => !specialCharactersRegexTest.test(val) + return decodedValues.every((val) => + ALLOWED_CHARACTERS_REGEX.test(val) ) }, }} @@ -757,11 +759,11 @@ export const Media = (): JSX.Element => { onClose={() => history.goBack()} validate={{ mediaDirectoryName: (value) => { - // NOTE: This value is prepended with either `files|images/` + // NOTE: This value is prepended with either `files|images` // and nested directories are separated by `/` as well. const decodedValues = decodeURIComponent(value).split("/") - return decodedValues.every( - (val) => !specialCharactersRegexTest.test(val) + return decodedValues.every((val) => + ALLOWED_CHARACTERS_REGEX.test(val) ) }, }}