File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed
Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 1+ node_modules
2+ .DS_Store *
3+ * .log
Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ module.exports = function(req){
2121
2222 // credentials
2323 auth = new Buffer ( auth , 'base64' ) . toString ( ) ;
24- auth = auth . match ( / ^ ( [ ^ : ] + ) : ( .* ) $ / ) ;
24+ auth = auth . match ( / ^ ( [ ^ : ] * ) : ( .* ) $ / ) ;
2525 if ( ! auth ) return ;
2626
2727 return { name : auth [ 1 ] , pass : auth [ 2 ] } ;
28- } ;
28+ } ;
Original file line number Diff line number Diff line change @@ -44,4 +44,18 @@ describe('auth(req)', function(){
4444 auth ( req ) . should . eql ( { name : 'foo' , pass : '' } ) ;
4545 } )
4646 } )
47+
48+ describe ( 'with empty userid' , function ( ) {
49+ it ( 'should return .user and .pass' , function ( ) {
50+ var req = request ( 'basic ' + new Buffer ( ':pass' ) . toString ( 'base64' ) ) ;
51+ auth ( req ) . should . eql ( { name : '' , pass : 'pass' } ) ;
52+ } )
53+ } )
54+
55+ describe ( 'with empty userid and pass' , function ( ) {
56+ it ( 'should return .user and .pass' , function ( ) {
57+ var req = request ( 'basic ' + new Buffer ( ':' ) . toString ( 'base64' ) ) ;
58+ auth ( req ) . should . eql ( { name : '' , pass : '' } ) ;
59+ } )
60+ } )
4761} )
You can’t perform that action at this time.
0 commit comments