Skip to content

Commit

Permalink
Merge fc6f7f6 into fd11e74
Browse files Browse the repository at this point in the history
  • Loading branch information
yads committed Dec 19, 2014
2 parents fd11e74 + fc6f7f6 commit 569cee8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var fs = require('fs');
var ms = require('ms');
var path = require('path');
var resolve = path.resolve;
var url = require('url');

/**
* Module variables.
Expand Down Expand Up @@ -58,7 +59,8 @@ module.exports = function favicon(path, options){
}

return function favicon(req, res, next){
if ('/favicon.ico' !== req.url) return next();
var requestPath = req.path || url.parse(req.url).pathname;
if ('/favicon.ico' !== requestPath) return next();

if ('GET' !== req.method && 'HEAD' !== req.method) {
var status = 'OPTIONS' === req.method ? 200 : 405;
Expand Down
7 changes: 7 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ describe('favicon()', function(){
});
});

it('should accept query string', function(done){
request(server)
.get('/favicon.ico?v=2')
.expect('Content-Type', 'image/x-icon')
.expect(200, done);
});

it('should ignore non-favicon requests', function(done){
request(server)
.get('/')
Expand Down

0 comments on commit 569cee8

Please sign in to comment.