Skip to content

Commit e286329

Browse files
authored
Merge pull request #138 from paul-rouse/master
On node.js don't override a base url already set in xhr2
2 parents ec9c50e + 3249a34 commit e286329

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/Affjax.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ exports._ajax = function () {
1313
return new XHR();
1414
};
1515

16-
platformSpecific.fixupUrl = function (url) {
17-
var urllib = module.require("url");
18-
var u = urllib.parse(url);
19-
u.protocol = u.protocol || "http:";
20-
u.hostname = u.hostname || "localhost";
21-
return urllib.format(u);
16+
platformSpecific.fixupUrl = function (url, xhr) {
17+
if (xhr.nodejsBaseUrl === null) {
18+
var urllib = module.require("url");
19+
var u = urllib.parse(url);
20+
u.protocol = u.protocol || "http:";
21+
u.hostname = u.hostname || "localhost";
22+
return urllib.format(u);
23+
} else {
24+
return url || "/";
25+
}
2226
};
2327

2428
platformSpecific.getResponse = function (xhr) {
@@ -42,7 +46,7 @@ exports._ajax = function () {
4246
return function (mkHeader, options) {
4347
return function (errback, callback) {
4448
var xhr = platformSpecific.newXHR();
45-
var fixedUrl = platformSpecific.fixupUrl(options.url);
49+
var fixedUrl = platformSpecific.fixupUrl(options.url, xhr);
4650
xhr.open(options.method || "GET", fixedUrl, true, options.username, options.password);
4751
if (options.headers) {
4852
try {

0 commit comments

Comments
 (0)