File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed
Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 11unreleased
22==========
33
4+ * Improve error message when ` req ` argument missing
45 * perf: enable strict mode
56 * perf: hoist regular expression
67 * perf: parse with regular expressions
Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ var userPassRegExp = /^([^:]*):(.*)$/
4646 */
4747
4848function auth ( req ) {
49+ if ( ! req ) {
50+ throw new TypeError ( 'argument req is required' )
51+ }
52+
4953 // get header
5054 var header = ( req . req || req ) . headers . authorization
5155
Original file line number Diff line number Diff line change @@ -9,7 +9,15 @@ function request(authorization) {
99 }
1010}
1111
12- describe ( 'auth(req)' , function ( ) {
12+ describe ( 'auth(req)' , function ( ) {
13+ describe ( 'arguments' , function ( ) {
14+ describe ( 'req' , function ( ) {
15+ it ( 'should be required' , function ( ) {
16+ assert . throws ( auth , / a r g u m e n t r e q i s r e q u i r e d / )
17+ } )
18+ } )
19+ } )
20+
1321 describe ( 'with no Authorization field' , function ( ) {
1422 it ( 'should return null' , function ( ) {
1523 var req = request ( ) ;
You can’t perform that action at this time.
0 commit comments