Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

change `res.redirect()` to utilize a pathname-relative Location again…

…. Closes #1382

nginx does not seem to set Host correctly,
though Location should be relative as per RFC
myself nor anyone else can report a client
that does not handle relative correctly so
this will be fine until then
  • Loading branch information...
commit c29cfa823d13f50ad56897006585f927b2195827 1 parent e183a96
@tj tj authored
Showing with 8 additions and 12 deletions.
  1. +0 −4 lib/response.js
  2. +8 −8 test/res.redirect.js
View
4 lib/response.js
@@ -652,10 +652,6 @@ res.redirect = function(url){
} else if ('/' != url[0]) {
url = path + '/' + url;
}
-
- // Absolute
- var host = req.get('Host');
- url = '//' + host + url;
}
// Support text/{plain,html} by default
View
16 test/res.redirect.js
@@ -51,7 +51,7 @@ describe('res', function(){
.get('/')
.set('Host', 'example.com')
.end(function(err, res){
- res.headers.should.have.property('location', '//example.com/login');
+ res.headers.should.have.property('location', '/login');
done();
})
})
@@ -69,7 +69,7 @@ describe('res', function(){
.get('/post/1')
.set('Host', 'example.com')
.end(function(err, res){
- res.headers.should.have.property('location', '//example.com/post/1/./edit');
+ res.headers.should.have.property('location', '/post/1/./edit');
done();
})
})
@@ -87,7 +87,7 @@ describe('res', function(){
.get('/post/1')
.set('Host', 'example.com')
.end(function(err, res){
- res.headers.should.have.property('location', '//example.com/post/1/../new');
+ res.headers.should.have.property('location', '/post/1/../new');
done();
})
})
@@ -105,7 +105,7 @@ describe('res', function(){
.get('/')
.set('Host', 'example.com')
.end(function(err, res){
- res.headers.should.have.property('location', '//example.com/login');
+ res.headers.should.have.property('location', '/login');
done();
})
})
@@ -129,7 +129,7 @@ describe('res', function(){
.get('/blog/admin')
.set('Host', 'example.com')
.end(function(err, res){
- res.headers.should.have.property('location', '//example.com/blog/admin/login');
+ res.headers.should.have.property('location', '/blog/admin/login');
done();
})
})
@@ -150,7 +150,7 @@ describe('res', function(){
.get('/blog')
.set('Host', 'example.com')
.end(function(err, res){
- res.headers.should.have.property('location', '//example.com/blog/admin/login');
+ res.headers.should.have.property('location', '/blog/admin/login');
done();
})
})
@@ -171,7 +171,7 @@ describe('res', function(){
.get('/blog')
.set('Host', 'example.com')
.end(function(err, res){
- res.headers.should.have.property('location', '//example.com/admin/login');
+ res.headers.should.have.property('location', '/admin/login');
done();
})
})
@@ -263,7 +263,7 @@ describe('res', function(){
.set('Host', 'http://example.com')
.set('Accept', 'text/html')
.end(function(err, res){
- res.text.should.equal('<p>Moved Temporarily. Redirecting to <a href="//http://example.com/&lt;lame&gt;">//http://example.com/&lt;lame&gt;</a></p>');
+ res.text.should.equal('<p>Moved Temporarily. Redirecting to <a href="/&lt;lame&gt;">/&lt;lame&gt;</a></p>');
done();
})
})
Please sign in to comment.
Something went wrong with that request. Please try again.