-
Notifications
You must be signed in to change notification settings - Fork 11
Add empty name validation to files #1427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,8 +9,12 @@ const allowedExtensions = { | |
| const reservedFileNames = ["INSTRUCTIONS.md"]; | ||
|
|
||
| const isValidFileName = (fileName, projectType, componentNames) => { | ||
| const extension = fileName.split(".").slice(1).join("."); | ||
| const parts = fileName.split("."); | ||
| const extension = parts.slice(1).join("."); | ||
| const baseName = parts[0]; | ||
|
|
||
| if ( | ||
| baseName.length > 0 && | ||
| !reservedFileNames.includes(fileName) && | ||
| allowedExtensions[projectType].includes(extension) && | ||
| !componentNames.includes(fileName) && | ||
|
|
@@ -31,7 +35,10 @@ export const validateFileName = ( | |
| callback, | ||
| currentFileName = null, | ||
| ) => { | ||
| const extension = fileName.split(".").slice(1).join("."); | ||
| const parts = fileName.split("."); | ||
| const extension = parts.slice(1).join("."); | ||
| const baseName = parts[0]; | ||
|
|
||
| if ( | ||
| isValidFileName(fileName, projectType, componentNames) || | ||
| (currentFileName && fileName === currentFileName) | ||
|
|
@@ -57,6 +64,8 @@ export const validateFileName = ( | |
| }), | ||
| ), | ||
| ); | ||
| } else if (baseName.length === 0) { | ||
| dispatch(setNameError(t("filePanel.errors.emptyFileName"))); | ||
jamiebenstead marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
64
to
+68
|
||
| } else { | ||
| dispatch(setNameError(t("filePanel.errors.generalError"))); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.