Skip to content

Commit 05ca726

Browse files
committed
Update github.js
Detect if we're in a browser environment
1 parent c44e23e commit 05ca726

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

github.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
return (root.Github = factory(XMLHttpRequest.XMLHttpRequest, b64encode.Base64.encode));
2222
});
2323
} else if (typeof module === 'object' && module.exports) {
24-
// Node. Does not work with strict CommonJS, but
25-
// only CommonJS-like enviroments that support module.exports,
26-
// like Node.
27-
module.exports = factory(XMLHttpRequest || require('xmlhttprequest').XMLHttpRequest, require('js-base64').Base64.encode);
24+
if (window) {
25+
module.exports = factory(window.XMLHttpRequest, window.btoa);
26+
} else {
27+
module.exports = factory(require('xmlhttprequest').XMLHttpRequest, require('js-base64').Base64.encode);
28+
}
2829
} else {
2930
// Browser globals
3031
var b64encode = function(str) {

0 commit comments

Comments
 (0)