diff --git a/src/components/MediaSettingsModal/MediaSettingsSchema.jsx b/src/components/MediaSettingsModal/MediaSettingsSchema.jsx index f89b85d99..26f6fbae1 100644 --- a/src/components/MediaSettingsModal/MediaSettingsSchema.jsx +++ b/src/components/MediaSettingsModal/MediaSettingsSchema.jsx @@ -27,6 +27,13 @@ export const MediaSettingsSchema = (existingTitlesArray = []) => return (value.match(/\./g) || []).length <= 1 } ) + .test( + "File not supported", + "File names must begin with a letter or number", + (value) => { + return /^[a-zA-Z0-9]/.test(value) + } + ) .min( MEDIA_SETTINGS_TITLE_MIN_LENGTH, `Title must be longer than ${MEDIA_SETTINGS_TITLE_MIN_LENGTH} characters` diff --git a/src/hooks/mediaHooks/useCreateMultipleMedia.ts b/src/hooks/mediaHooks/useCreateMultipleMedia.ts index 58f71e697..fe10cf6e2 100644 --- a/src/hooks/mediaHooks/useCreateMultipleMedia.ts +++ b/src/hooks/mediaHooks/useCreateMultipleMedia.ts @@ -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)}`, })) )