Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+33 added−2 removed
tests:+30 added−0 removed
other:+3 added−2 removed
Provenance
Commit
6f0302f
Tree
8957c52
Author
Alex Upadhyay <prafu@amazon.com>
Committer
Douglas Christopher Wilson <doug@somethingdoug.com>
Parent
6f91416
3 files changed+33 added−2 removed
modified:lib/response.js+2 added-2 removed
816 unmodified lines
817818 // Support text/{plain,html} by default819 this.format({820 text: function(){821- body = statusCodes[status] + '. Redirecting to ' + encodeURI(url);821+ body = statusCodes[status] + '. Redirecting to ' + encodeURI(address);822 },823824 html: function(){825- var u = escapeHtml(url);825+ var u = escapeHtml(address);826 body = '<p>' + statusCodes[status] + '. Redirecting to <a href="' + u + '">' + u + '</a></p>';827 },828829 default: function(){
138 unmodified lines
modified:test/res.redirect.js+30 added
104 unmodified lines
Expand all
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
29 unmodified lines
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
19 unmodified lines
104 unmodified lines
Expand all
res.text.should.equal('<p>Moved Temporarily. Redirecting to <a href="<lame>"><lame></a></p>');
done();
})
})
it('should include the redirect type', function(done){
var app = express();
app.use(function(req, res){
res.redirect(301, 'http://google.com');
});
request(app)
.get('/')
.set('Accept', 'text/html')
.expect('Content-Type', /html/)
.expect('Location', 'http://google.com')
.expect(301, '<p>Moved Permanently. Redirecting to <a href="http://google.com">http://google.com</a></p>', done);
})
})
describe('when accepting text', function(){
it('should respond with text', function(done){
29 unmodified lines
res.text.should.equal('Moved Temporarily. Redirecting to http://example.com/?param=%3Cscript%3Ealert(%22hax%22);%3C/script%3E');
done();
})
})
it('should include the redirect type', function(done){
var app = express();
app.use(function(req, res){
res.redirect(301, 'http://google.com');
});
request(app)
.get('/')
.set('Accept', 'text/plain, */*')
.expect('Content-Type', /plain/)
.expect('Location', 'http://google.com')
.expect(301, 'Moved Permanently. Redirecting to http://google.com', done);
})
})
describe('when accepting neither text or html', function(){
it('should respond with an empty body', function(done){
19 unmodified lines
modified:History.md+1 added
1unreleased2==========34+ * Fix `res.redirect` body when redirect status specified5 * deps: accepts@~1.1.26 - Fix error when media type has invalid parameter7 - deps: negotiator@0.4.98