Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Port should default to window.location.port, not 80, if not specified #60

MadMartian opened this Issue · 4 comments

5 participants


The port should not default to port 80 if not specified in a request. Instead it should default to the value obtained from window.location.port unless it is undefined in which case it should default to 80.

This snippet:

port: {
    get: function() {
      if (!this._port) {
        switch(this.scheme) {
          case "https": return this._port = 443;
          case "http":
          default: return this._port = 80;
      return this._port;
    set: function(value) { this._port = value; return this; },
    enumerable: true

Conflicts with this snippet:

http.request = function (params, cb) {
    if (!params) params = {};
    if (! =':')[0];
    if (!params.port) params.port = window.location.port;

    var req = new Request(new xhrHttp, params);
    if (cb) req.on('response', cb);
    return req;

When issuing a request using a relative path that omits the scheme, host, and port. The library correctly obtains the host from, but does not correctly obtain the port from window.location.port.


Also ran into this one, thanks for the fix @MadMartian


Probable fix for this is now in master. I don't have browser tests set up at the moment, so I won't publish a release yet.


Leaving this open for now, as part of the NG release plan. We'll use this fix as a model. See also: #71, #72.


BTW, I think I see a related bug looking at the current master - is defaulting to window?.port, but I think that should be location?.port or window?.location?.port (equivalent, but the latter is more obvious if you're not thinking about a client-side context)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.