pybricksMicropython: don't allow files with dash

Since we are adding user imports, we need to make sure all file names
are valid module names, so this means we can't use a dash.
This commit is contained in:
David Lechner
2022-10-19 18:26:37 -05:00
committed by David Lechner
parent 81d52dbc52
commit 8b19ad5866
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -34,9 +34,9 @@ describe('validateFileName', () => {
);
});
it('should allow file names with dashes', () => {
it('should not allow file names with dashes', () => {
expect(validateFileName('file-name', pythonFileExtension, [])).toBe(
FileNameValidationResult.IsOk,
FileNameValidationResult.HasInvalidCharacters,
);
});
+1 -1
View File
@@ -61,7 +61,7 @@ export function validateFileName(
return FileNameValidationResult.HasInvalidFirstCharacter;
}
if (!fileName.match(/^[a-zA-Z0-9_-]+$/)) {
if (!fileName.match(/^[a-zA-Z0-9_]+$/)) {
return FileNameValidationResult.HasInvalidCharacters;
}