Skip to content
Myr

remove non-primitive string support for `res.send()`

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

kinda silly.. valueOf() before if you happen to use boxed strings, otherwise it is unfair that dont support other boxed primitives all over, and quite frankly no one does

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent 88072a5 · Browse files · 2 files+0 added−39 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+0 added−39 removed

  • tests:+0 added−36 removed
  • other:+0 added−3 removed

2 files+0 added−39 removed

modified:lib/response.js-3 removed
93 unmodified lines
94 body = arguments[1];95 }96 }9798 // convert string objects to primitives99 if (body instanceof String) body = body.toString();10098 switch (typeof body) {99 // response status100 case 'number':101 this.get('Content-Type') || this.type('txt');
615 unmodified lines
modified:test/res.send.js-36 removed
121 unmodified lines
122 .expect(200, done);123 })124 })125 126 describe('.send(StringObj)', function(){127 it('should send as html', function(done){128 var app = express();129130 app.use(function(req, res){131 res.send(new String('<p>hey</p>'));132 });133134 request(app)135 .get('/')136 .end(function(err, res){137 res.headers.should.have.property('content-type', 'text/html; charset=utf-8');138 res.text.should.equal('<p>hey</p>');139 res.statusCode.should.equal(200);140 done();141 })142 })143 144 it('should not override Content-Type', function(done){145 var app = express();146147 app.use(function(req, res){148 res.set('Content-Type', 'text/plain').send(new String('hey'));149 });150151 request(app)152 .get('/')153 .end(function(err, res){154 res.headers.should.have.property('content-type', 'text/plain');155 res.text.should.equal('hey');156 res.statusCode.should.equal(200);157 done();158 })159 })160 })161 126 describe('.send(Buffer)', function(){127 it('should send as octet-stream', function(done){128 var app = express();129
172 unmodified lines