No need to check if the first character is a number. This is already validated before.

This commit is contained in:
amzn-sj
2021-06-10 13:34:16 -07:00
parent 0aba7911a2
commit 607f32fae6
2 changed files with 4 additions and 3 deletions
+4
View File
@@ -1894,6 +1894,10 @@ def create_gem(gem_path: str,
# gem name is now the last component of the gem_path
gem_name = os.path.basename(gem_path)
if not utils.validate_identifier(gem_name):
logger.error(f'Gem name must be fewer than 64 characters, contain only alphanumeric, "_" or "-" characters, and start with a letter. {gem_name}')
return 1
# gem name cannot be the same as a restricted platform name
if gem_name in restricted_platforms:
logger.error(f'Gem path cannot be a restricted name. {gem_name}')
-3
View File
@@ -46,9 +46,6 @@ def sanitize_identifier_for_cpp(identifier: str) -> str:
return ''
sanitized_identifier = list(identifier)
if not (sanitized_identifier[0].isalpha() or sanitized_identifier[0] == '_'):
sanitized_identifier.insert(0, '_')
for index, character in enumerate(sanitized_identifier):
if not (character.isalnum() or character == '_'):
sanitized_identifier[index] = '_'