Skip to content
Myr

Merge branch 'integration'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parents 1879648, 5a11f82 · Browse files · 2 files+40 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+40 added−5 removed

  • tests:+23 added−0 removed
  • other:+17 added−5 removed

2 files+40 added−5 removed

modified:lib/express/request.js+17 added-5 removed
111 unmodified lines
112 },113 114 /**115 * Check if Accept header includes the mime type116 * for the given _path_, which calls mime.type().116 * for any of the given paths, which calls mime.type().117 *118 * When no Accept header is present true will be119 * returned as stated in the HTTP specification.120 *121 * @param {string} path121 * Example:122 *123 * this.accepts('png')124 * this.accepts('png', 'jpg', 'gif')125 * this.accepts('image.png')126 * this.accepts('path/to/image.png')127 *128 * @param {mixed} ...129 * @return {bool}130 * @api public131 */132126 accepts: function(path) {127 return this.header('accept') ? 128 this.header('accept').indexOf(mime.type(path)) !== -1 :133 accepts: function() {134 var accept = this.header('accept')135 return accept ? 136 $(arguments).any(function(path){137 var type = mime.type(path)138 return accept.indexOf(type) !== -1 ||139 accept.indexOf(type.split('/')[0]+'/*') !== -1140 }) :141 true142 },143144 /**
130 unmodified lines
modified:spec/spec.request.js+23 added
56 unmodified lines
57 get('/user', function(){ return this.accepts('jpeg').toString() })58 get('/user', { headers: { accept: null }}).body.should.eql 'true'59 end60 end61 62 describe 'should allow multiple arguments'63 it 'should return true if any mime type is present'64 get('/user', function(){ return this.accepts('jpeg', 'png').toString() })65 get('/user', { headers: { accept: 'image/gif,image/png' }}).body.should.eql 'true'66 end67 68 it 'should return false if none of the mime types are present'69 get('/user', function(){ return this.accepts('jpeg', 'png').toString() })70 get('/user', { headers: { accept: 'text/plain,text/html' }}).body.should.eql 'false'71 end72 end73 74 describe 'when a media type range was sent'75 it 'should return true if the group media type matches'76 get('/user', function(){ return this.accepts('html').toString() })77 get('/user', { headers: { accept: 'text/plain,text/*' }}).body.should.eql 'true'78 end79 it 'should return false if the group media type does not match'80 get('/user', function(){ return this.accepts('ogg').toString() })81 get('/user', { headers: { accept: 'text/plain,text/*' }}).body.should.eql 'false'82 end83 end84 end85 86 describe '#halt()'87 describe 'when given no arguments'
128 unmodified lines