Skip to content

Commit

Permalink
fix(media): update routes (#1862)
Browse files Browse the repository at this point in the history
  • Loading branch information
seaerchin authored Mar 21, 2024
1 parent 3b12a98 commit 3b84d34
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/layouts/Media/Media.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
},
}}
/>
Expand All @@ -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)
)
},
}}
Expand All @@ -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)
)
},
}}
Expand Down

0 comments on commit 3b84d34

Please sign in to comment.