File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ function check(username, token) {
2828 if ( typeof token !== 'string' ) {
2929 errorExit ( `token must be a string, received ${ typeof token } ` ) ;
3030 }
31- if ( ! / ^ [ 0 - 9 a - f ] + $ / . test ( token ) ) {
32- errorExit ( `token must be lowercase hexadecimal, received ${ token } ` ) ;
31+ if ( ! / ^ [ A - Z a - z 0 - 9 _ ] + $ / . test ( token ) ) {
32+ errorExit ( `token is misformatted: ${ token } ` ) ;
3333 }
3434}
3535
Original file line number Diff line number Diff line change @@ -102,9 +102,25 @@ describe('auth', async function() {
102102 it ( 'does not accept an invalid token format' , async function ( ) {
103103 this . timeout ( 2000 ) ;
104104 await runAuthScript (
105- { HOME : { username : 'nyancat' , token : '0123456789ABCDEF ' } } ,
105+ { HOME : { username : 'nyancat' , token : '@fhqwhgads ' } } ,
106106 [ ] ,
107- 'token must be lowercase hexadecimal, received 0123456789ABCDEF\n'
107+ 'token is misformatted: @fhqwhgads\n'
108+ ) ;
109+ } ) ;
110+
111+ it ( 'permits capital letters in token format' , async function ( ) {
112+ this . timeout ( 2000 ) ;
113+ await runAuthScript (
114+ { HOME : { username : 'nyancat' , token : '0123456789ABCDEF' } } ,
115+ [ '{"github":"bnlhbmNhdDowMTIzNDU2Nzg5QUJDREVG"}' ]
116+ ) ;
117+ } ) ;
118+
119+ it ( 'permits underscores in token format' , async function ( ) {
120+ this . timeout ( 2000 ) ;
121+ await runAuthScript (
122+ { HOME : { username : 'nyancat' , token : 'ghp_0123456789ABCDEF' } } ,
123+ [ '{"github":"bnlhbmNhdDpnaHBfMDEyMzQ1Njc4OUFCQ0RFRg=="}' ]
108124 ) ;
109125 } ) ;
110126} ) ;
You can’t perform that action at this time.
0 commit comments