http-browserify icon indicating copy to clipboard operation
http-browserify copied to clipboard

http browserify broken when sending a full node url object

Open panthershark opened this issue 11 years ago • 2 comments

var url = { 
    host: "localhost:8081",
    hostname: "localhost",
    href: "http://localhost:8081/api/foo?bar=baz",
    method: "GET",
    path: "/api/foo?bar=baz",
    pathname: "/api/foo",
    port: "8081",
    protocol: "http:",
    query: "bar=baz",
    search: "?bar=baz",
    slashes: true
  };
  var request = http.get(url, noop);
expected: "http://localhost:8081/api/foo?bar=baz"
actual:   "http://localhost:8081:8081/api/foo?bar=baz"

The url that is requested has the port in it 2 times. This is because of this line.
https://github.com/substack/http-browserify/blob/master/index.js#L7

I am finishing up a pull request to fix this where it will try host first, then hostname+port.

Please let me know if you have any input.

panthershark avatar Oct 08 '13 21:10 panthershark

+1.

SQUARE-WAVES avatar Nov 11 '13 18:11 SQUARE-WAVES

+1

cappslock avatar Nov 11 '13 18:11 cappslock