@@ -73,12 +73,12 @@ enum ValidByte {
73
73
}
74
74
75
75
impl ValidByte {
76
- fn lower_alpha ( byte : u8 ) -> Option < Self > {
77
- byte. is_ascii_lowercase ( ) . then_some ( Self :: Byte ( byte) )
76
+ fn alpha_numeric ( byte : u8 ) -> Option < Self > {
77
+ byte. is_ascii_alphanumeric ( ) . then_some ( Self :: Byte ( byte) )
78
78
}
79
79
80
- fn lower_alpha_hyphen ( byte : u8 ) -> Option < Self > {
81
- matches ! ( byte, b'a' ..= b'z' | b'-' ) . then_some ( Self :: Byte ( byte) )
80
+ fn alpha_numeric_hyphen ( byte : u8 ) -> Option < Self > {
81
+ ( byte. is_ascii_alphanumeric ( ) || byte == b'-' ) . then_some ( Self :: Byte ( byte) )
82
82
}
83
83
84
84
fn next ( & self , next : u8 ) -> Option < ValidByte > {
@@ -87,9 +87,9 @@ impl ValidByte {
87
87
( ValidByte :: Separator , b'-' ) => None ,
88
88
89
89
( _, IDENTIFIER_SEPARATOR ) => Some ( ValidByte :: Separator ) ,
90
- ( ValidByte :: Separator , next) => ValidByte :: lower_alpha ( next) ,
91
- ( ValidByte :: Byte ( b'-' ) , next) => ValidByte :: lower_alpha ( next) ,
92
- ( ValidByte :: Byte ( _) , next) => ValidByte :: lower_alpha_hyphen ( next) ,
90
+ ( ValidByte :: Separator , next) => ValidByte :: alpha_numeric ( next) ,
91
+ ( ValidByte :: Byte ( b'-' ) , next) => ValidByte :: alpha_numeric ( next) ,
92
+ ( ValidByte :: Byte ( _) , next) => ValidByte :: alpha_numeric_hyphen ( next) ,
93
93
}
94
94
}
95
95
}
@@ -149,7 +149,7 @@ impl TryFrom<String> for Identifier {
149
149
// grab the first byte only before parsing the rest
150
150
let mut prev = bytes
151
151
. next ( )
152
- . and_then ( ValidByte :: lower_alpha )
152
+ . and_then ( ValidByte :: alpha_numeric )
153
153
. ok_or ( Self :: Error :: InvalidFormat ) ?;
154
154
155
155
let mut idx = 0 ;
@@ -222,6 +222,8 @@ mod tests {
222
222
#[ test]
223
223
fn format ( ) {
224
224
assert ! ( ident( "prefix:base" ) . is_ok( ) ) ;
225
+ assert ! ( ident( "prefix3:base" ) . is_ok( ) ) ;
226
+ assert ! ( ident( "preFix:base" ) . is_ok( ) ) ;
225
227
226
228
// bad
227
229
assert ! ( ident( "tauri-plugin-prefix:base" ) . is_err( ) ) ;
0 commit comments