Closed MrSwitch closed 10 years ago
Whilst this does fix it for me,. i think i have another problem, something is stripping out chunks of code,
e.g. for instance this is what browserify puts together...
http.request = function (params, cb) {
if (!params) params = {};
if (!params.host && !params.port) {
params.port = parseInt(window.location.port, 10);
}
if (!params.host) params.host = window.location.hostname;
if (!params.port) params.port = 80;
if (!params.scheme) params.scheme = window.location.protocol.split(':')[0];
var req = new Request(new xhrHttp, params);
if (cb) req.on('response', cb);
return req;
};
And this is how its written in http-browserify/index.js
http.request = function (params, cb) {
if (typeof params === 'string') {
params = url.parse(params)
}
if (!params) params = {};
if (!params.host && !params.port) {
params.port = parseInt(window.location.port, 10);
}
if (!params.host && params.hostname) {
params.host = params.hostname;
}
if (!params.scheme) params.scheme = window.location.protocol.split(':')[0];
if (!params.host) {
params.host = window.location.hostname || window.location.host;
}
if (/:/.test(params.host)) {
if (!params.port) {
params.port = params.host.split(':')[1];
}
params.host = params.host.split(':')[0];
}
if (!params.port) params.port = params.scheme == 'https' ? 443 : 80;
var req = new Request(new xhrHttp, params);
if (cb) req.on('response', cb);
return req;
};
That looks like just a version mismatch. Anyways published in 1.4.1.
So i just npm installed it all today grunt-watchify is on an old version of browserify "2.36.1" ...
Subsequently is on http-browserify is on "version": "0.1.14" ....
\grunt-watchify\node_modules\browserify\node_modules\browser-builtins\node_modules\http-browserify\index.js:
Solution, avoid grunt-watchify, use grunt-contrib-watch instead
Bug, given a parsed URL, e.g... { host : 'localhost:3000', port : '3000' }
The Request object will append the ports twice, which is a bug.
See fix...