Skip to content

Commit c2dbc95

Browse files
committed
Fixing issue with redirects not being followed correctly
1 parent 4c6c4a8 commit c2dbc95

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
test
22
.eslintrc
3-
examples.js
3+
examples.js
4+
uploads

lib/httpreq.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ function doRequest (o, callback) {
361361

362362
if (o.redirectCount < o.maxRedirects) {
363363
o.redirectCount++;
364-
o.url = res.headers.location;
364+
o.url = (new URL(res.headers.location, o.url)).href; // location can be the path only (no base url present)
365365
o.cookies = extractCookies (res.headers);
366366
return doRequest (o, finalCallback);
367367
} else {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "httpreq",
33
"description": "node-httpreq is a node.js library to do HTTP(S) requests the easy way",
4-
"version": "0.5.1",
4+
"version": "0.5.2",
55
"author": {
66
"name": "Sam Decrock",
77
"url": "https://github.com/SamDecrock/"
@@ -10,7 +10,7 @@
1010
"url": "https://github.com/SamDecrock/node-httpreq/issues"
1111
},
1212
"engines": {
13-
"node": ">= 0.8.0"
13+
"node": ">= 6.15.1"
1414
},
1515
"repository": {
1616
"type": "git",

0 commit comments

Comments
 (0)