File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed
Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 11unreleased
22==========
33
4+ * Ignore requests without ` url ` property
45 * deps: ms@2.1.1
56 - Add ` week `
67 - Add ` w `
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ function favicon (path, options) {
6464 }
6565
6666 return function favicon ( req , res , next ) {
67- if ( parseUrl ( req ) . pathname !== '/favicon.ico' ) {
67+ if ( getPathname ( req ) !== '/favicon.ico' ) {
6868 next ( )
6969 return
7070 }
@@ -144,6 +144,21 @@ function createIsDirError (path) {
144144 return error
145145}
146146
147+ /**
148+ * Get the request pathname.
149+ *
150+ * @param {object } req
151+ * @return {string }
152+ */
153+
154+ function getPathname ( req ) {
155+ try {
156+ return parseUrl ( req ) . pathname
157+ } catch ( e ) {
158+ return undefined
159+ }
160+ }
161+
147162/**
148163 * Determine if the cached representation is fresh.
149164 *
Original file line number Diff line number Diff line change @@ -183,6 +183,13 @@ describe('favicon()', function () {
183183 . expect ( 'Content-Type' , 'image/x-icon' )
184184 . expect ( 200 , done )
185185 } )
186+
187+ describe ( 'missing req.url' , function ( ) {
188+ it ( 'should ignore the request' , function ( done ) {
189+ var fn = favicon ( ICON_PATH )
190+ fn ( { } , { } , done )
191+ } )
192+ } )
186193 } )
187194
188195 describe ( 'icon' , function ( ) {
You can’t perform that action at this time.
0 commit comments