File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -75,10 +75,7 @@ impl Token {
7575/// This performs the following checks on a given token:
7676/// - Is not empty;
7777/// - Is optionally prefixed with `"Bot "` or `"Bearer "`;
78- /// - Contains 3 parts (split by the period char `'.'`);
79- ///
80- /// Note that a token prefixed with `"Bearer "` will have its prefix changed to `"Bot "` when
81- /// parsed.
78+ /// - Contains 3 parts (for bot tokens) (split by the period char `'.'`);
8279///
8380/// # Examples
8481///
@@ -102,7 +99,11 @@ impl FromStr for Token {
10299 type Err = TokenError ;
103100
104101 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
105- let token = s. trim ( ) . trim_start_matches ( "Bot " ) . trim_start_matches ( "Bearer " ) ;
102+ if s. starts_with ( "Bearer " ) {
103+ return Ok ( Self ( SecretString :: new ( Arc :: from ( s) ) ) ) ;
104+ }
105+
106+ let token = s. trim ( ) . trim_start_matches ( "Bot " ) ;
106107
107108 let mut parts = token. split ( '.' ) ;
108109 let is_valid = parts. next ( ) . is_some_and ( |p| !p. is_empty ( ) )
You can’t perform that action at this time.
0 commit comments