Skip to content

Commit 5de8cdc

Browse files
dbhowelljonathanong
authored andcommitted
Support empty password
fixes #4
1 parent 055daee commit 5de8cdc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ 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] };

test/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,11 @@ describe('auth(req)', function(){
3737
auth(req).should.eql({ name: 'foo', pass: 'bar' });
3838
})
3939
})
40+
41+
describe('with empty password', function(){
42+
it('should return .user and .pass', function(){
43+
var req = request('basic Zm9vOg==');
44+
auth(req).should.eql({ name: 'foo', pass: ''});
45+
})
46+
})
4047
})

0 commit comments

Comments
 (0)