Skip to content

Commit 8405f05

Browse files
committed
Handle raw responseText and consider 200+ status codes.
1 parent 52b700a commit 8405f05

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

github.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Github.js 0.6.2
1+
// Github.js 0.6.2
22
// (c) 2012 Michael Aufreiter, Development Seed
33
// Github.js is freely distributable under the MIT license.
44
// For all details and documentation:
@@ -19,7 +19,11 @@
1919
xhr.open(method, API_URL + path);
2020
xhr.onreadystatechange = function () {
2121
if (this.readyState == 4) {
22-
this.status == 200 ? cb(null, JSON.parse(this.responseText)) : cb(this.status);
22+
if (this.status >= 200 && this.status < 300) {
23+
cb(null, raw ? this.responseText : JSON.parse(this.responseText));
24+
} else {
25+
cb(this.status);
26+
}
2327
}
2428
}
2529
xhr.setRequestHeader('Accept','application/vnd.github.raw');
@@ -201,6 +205,7 @@
201205
]
202206
};
203207
_request("POST", repoPath + "/git/trees", data, function(err, res) {
208+
console.log('RES', res, "ERR", err);
204209
if (err) return cb(err);
205210
cb(null, res.sha);
206211
});

0 commit comments

Comments
 (0)