File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -25,17 +25,17 @@ export const CLASS_NAME_TELEOP = 'Teleop';
2525export const JSON_FILE_EXTENSION = '.json' ;
2626export const UPLOAD_DOWNLOAD_FILE_EXTENSION = '.blocks' ;
2727
28- /**
29- * Regular expression to extract the project name and the class name from a module path.
30- */
31- const REGEX_MODULE_PATH = '^([A-Za-z_][A-Za-z0-9_]*)/([A-Za-z_][A-Za-z0-9_]*).json $';
28+ const REGEX_PROJECT_OR_CLASS_NAME_PART = '[A-Z][A-Za-z0-9]*' ;
29+ const REGEX_CLASS_NAME = '^' + REGEX_PROJECT_OR_CLASS_NAME_PART + '$' ;
30+ const REGEX_MODULE_PATH = '^(' + REGEX_PROJECT_OR_CLASS_NAME_PART + ')/(' +
31+ REGEX_PROJECT_OR_CLASS_NAME_PART + ')' + escapeRegExp ( JSON_FILE_EXTENSION ) + ' $';
3232
3333/**
3434 * Returns true if the given name is a valid class name.
3535 */
3636export function isValidClassName ( name : string ) : boolean {
3737 if ( name ) {
38- return / ^ [ A - Z ] [ A - Z a - z 0 - 9 ] * $ / . test ( name ) ;
38+ return new RegExp ( REGEX_CLASS_NAME ) . test ( name ) ;
3939 }
4040 return false ;
4141}
@@ -79,9 +79,8 @@ export function snakeCaseToPascalCase(snakeCaseName: string): string {
7979 * Returns the module path regex pattern for modules in the given project.
8080 */
8181export function makeModulePathRegexPattern ( projectName : string ) : string {
82- const prefix = projectName + '/' ;
83- const suffix = JSON_FILE_EXTENSION ;
84- return '^' + escapeRegExp ( prefix ) + '.*' + escapeRegExp ( suffix ) + '$' ;
82+ return '^' + escapeRegExp ( projectName ) + '/' + REGEX_PROJECT_OR_CLASS_NAME_PART +
83+ escapeRegExp ( JSON_FILE_EXTENSION ) + '$' ;
8584}
8685
8786function escapeRegExp ( text : string ) : string {
You can’t perform that action at this time.
0 commit comments