@@ -578,10 +578,11 @@ fn check_safe_app_name(name: &str) -> Result<()> {
578
578
// The path consists of slash-separated components. Each component may contain lowercase letters, digits and separators.
579
579
// A separator is defined as a period, one or two underscores, or one or more hyphens. A component may not start or end with a separator.
580
580
fn sanitize_app_name ( name : & str ) -> String {
581
+ let trim_chars = [ '.' , '_' , '-' ] ;
581
582
name. to_ascii_lowercase ( )
582
583
. replace ( ' ' , "" )
583
- . trim_start_matches ( | c : char | c == '.' || c == '_' || c == '-' )
584
- . trim_end_matches ( | c : char | c == '.' || c == '_' || c == '-' )
584
+ . trim_start_matches ( trim_chars )
585
+ . trim_end_matches ( trim_chars )
585
586
. to_string ( )
586
587
}
587
588
@@ -590,9 +591,7 @@ fn sanitize_app_name(name: &str) -> String {
590
591
// A tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores, periods and hyphens.
591
592
// A tag name may not start with a period or a hyphen and may contain a maximum of 128 characters.
592
593
fn sanitize_app_version ( tag : & str ) -> String {
593
- let mut sanitized = tag
594
- . trim ( )
595
- . trim_start_matches ( |c : char | c == '.' || c == '-' ) ;
594
+ let mut sanitized = tag. trim ( ) . trim_start_matches ( [ '.' , '-' ] ) ;
596
595
597
596
if sanitized. len ( ) > 128 {
598
597
( sanitized, _) = sanitized. split_at ( 128 ) ;
0 commit comments