Skip to content

Commit

Permalink
fix(images): should begin with letter
Browse files Browse the repository at this point in the history
  • Loading branch information
kishore03109 committed Mar 11, 2024
1 parent 46925f0 commit 74aa4e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/MediaSettingsModal/MediaSettingsSchema.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export const MediaSettingsSchema = (existingTitlesArray = []) =>
)
.test(
"File not supported",
"File names cannot begin with an underscore",
"File names must begin with a letter or number",
(value) => {
return !value.startsWith("_")
return /^[a-zA-Z0-9]/.test(value)
}
)
.min(
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/mediaHooks/useCreateMultipleMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export const useCreateMultipleMedia = (
// with a safe replacement character
newFileName: `${getFileName(file.name)
.replaceAll(/[\W\s]/g, "_")
// Remove any leading underscores
.replace(/^_+/g, "")
.trim()}.${getFileExt(file.name)}`,
}))
)
Expand Down

0 comments on commit 74aa4e0

Please sign in to comment.