Skip to content

Commit

Permalink
Rename redirectUrl into responseUrl.
Browse files Browse the repository at this point in the history
The name redirectUrl didn't make sense for those cases
where the request was not actually redirected.
  • Loading branch information
RubenVerborgh committed Oct 23, 2016
1 parent efc8dde commit 721fae6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
this._performRequest();
} else {
// The response is not a redirect; return it as-is
response.redirectUrl = this._currentUrl;
response.responseUrl = this._currentUrl;
return this.emit('response', response);
}
};
Expand Down
22 changes: 11 additions & 11 deletions test/test-with-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('follow-redirects ', function () {
}))
.then(function (res) {
assert.deepEqual(res.parsedJson, {a: 'b'});
assert.deepEqual(res.redirectUrl, 'http://localhost:3600/f');
assert.deepEqual(res.responseUrl, 'http://localhost:3600/f');
})
.nodeify(done);
});
Expand All @@ -80,7 +80,7 @@ describe('follow-redirects ', function () {
}))
.then(function (res) {
assert.deepEqual(res.parsedJson, {a: 'b'});
assert.deepEqual(res.redirectUrl, 'http://localhost:3600/f');
assert.deepEqual(res.responseUrl, 'http://localhost:3600/f');
})
.nodeify(done);
});
Expand All @@ -96,7 +96,7 @@ describe('follow-redirects ', function () {
}))
.then(function (res) {
assert.equal(res.statusCode, 307);
assert.deepEqual(res.redirectUrl, 'http://localhost:3600/a');
assert.deepEqual(res.responseUrl, 'http://localhost:3600/a');
res.on('data', function () {
// noop to consume the stream (server won't shut down otherwise).
});
Expand Down Expand Up @@ -130,7 +130,7 @@ describe('follow-redirects ', function () {
}))
.then(function (res) {
assert.deepEqual(res.parsedJson, {baz: 'quz'});
assert.deepEqual(res.redirectUrl, 'https://localhost:3601/c');
assert.deepEqual(res.responseUrl, 'https://localhost:3601/c');
})
.nodeify(done);
});
Expand All @@ -147,7 +147,7 @@ describe('follow-redirects ', function () {
}))
.then(function (res) {
assert.deepEqual(res.parsedJson, {greeting: 'hello'});
assert.deepEqual(res.redirectUrl, 'http://localhost:3600/b?greeting=hello');
assert.deepEqual(res.responseUrl, 'http://localhost:3600/b?greeting=hello');
})
.nodeify(done);
});
Expand Down Expand Up @@ -247,7 +247,7 @@ describe('follow-redirects ', function () {
}))
.then(function (res) {
assert.deepEqual(res.parsedJson, {foo: 'bar'});
assert.deepEqual(res.redirectUrl, 'http://localhost:3600/r0');
assert.deepEqual(res.responseUrl, 'http://localhost:3600/r0');
})
// 22 redirects should fail
.then(asPromise(function (resolve, reject) {
Expand All @@ -267,7 +267,7 @@ describe('follow-redirects ', function () {
}))
.then(function (res) {
assert.deepEqual(res.parsedJson, {foo: 'bar'});
assert.deepEqual(res.redirectUrl, 'http://localhost:3600/r0');
assert.deepEqual(res.responseUrl, 'http://localhost:3600/r0');
})
.nodeify(done);
});
Expand Down Expand Up @@ -314,7 +314,7 @@ describe('follow-redirects ', function () {
http.request(opts, resolve).on('error', reject).end();
}))
.then(function (res) {
assert.deepEqual(res.redirectUrl, 'http://localhost:3600/b');
assert.deepEqual(res.responseUrl, 'http://localhost:3600/b');
if (res.statusCode !== 200) {
throw new Error('Did not use ' + expectedMethod);
}
Expand Down Expand Up @@ -344,7 +344,7 @@ describe('follow-redirects ', function () {
}))
.then(function (res) {
assert.deepEqual(res.parsedJson, {yes: 'no'});
assert.deepEqual(res.redirectUrl, 'https://localhost:3601/c');
assert.deepEqual(res.responseUrl, 'https://localhost:3601/c');
})
.nodeify(done);
});
Expand All @@ -362,7 +362,7 @@ describe('follow-redirects ', function () {
}))
.then(function (res) {
assert.deepEqual(res.parsedJson, {hello: 'goodbye'});
assert.deepEqual(res.redirectUrl, 'http://localhost:3600/c');
assert.deepEqual(res.responseUrl, 'http://localhost:3600/c');
})
.nodeify(done);
});
Expand Down Expand Up @@ -410,7 +410,7 @@ describe('follow-redirects ', function () {
}))
.then(function (res) {
assert.deepEqual(res.statusCode, 302);
assert.deepEqual(res.redirectUrl, 'http://localhost:3600/a');
assert.deepEqual(res.responseUrl, 'http://localhost:3600/a');
})
.nodeify(done);
});
Expand Down

0 comments on commit 721fae6

Please sign in to comment.