mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-29 21:22:55 +03:00
Merge pull request #838 from AleoHQ/fix-package-name-check
Fix package name checks
This commit is contained in:
commit
8b254b6b10
@ -68,10 +68,16 @@ impl Package {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that the first character is not a number.
|
||||
if previous.is_numeric() {
|
||||
tracing::error!("Project names cannot begin with a number");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Iterate and check that the package name is valid.
|
||||
for current in package_name.chars() {
|
||||
// Check that the package name is lowercase.
|
||||
if !current.is_ascii_lowercase() && current != '-' {
|
||||
if current.is_ascii_uppercase() && current != '-' {
|
||||
tracing::error!("Project names must be all lowercase");
|
||||
return false;
|
||||
}
|
||||
@ -267,6 +273,8 @@ mod tests {
|
||||
assert!(Package::is_package_name_valid("foo"));
|
||||
assert!(Package::is_package_name_valid("foo-bar"));
|
||||
assert!(Package::is_package_name_valid("foo-bar-baz"));
|
||||
assert!(Package::is_package_name_valid("foo1"));
|
||||
assert!(Package::is_package_name_valid("foo-1"));
|
||||
|
||||
assert!(!Package::is_package_name_valid(""));
|
||||
assert!(!Package::is_package_name_valid("-"));
|
||||
@ -279,5 +287,6 @@ mod tests {
|
||||
assert!(!Package::is_package_name_valid("foo*bar"));
|
||||
assert!(!Package::is_package_name_valid("foo,bar"));
|
||||
assert!(!Package::is_package_name_valid("foo_bar"));
|
||||
assert!(!Package::is_package_name_valid("1-foo"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user