Browse files

Fix global scope leak, and amend decision on when to use https or htt…

…p libraries
  • Loading branch information...
1 parent 1970e00 commit ef51782104b8f9838741a9373e190ca0cca6505e @ciaranj committed Apr 24, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/oauth2.js
View
9 lib/oauth2.js
@@ -29,13 +29,16 @@ exports.OAuth2.prototype._getAccessTokenUrl= function() {
exports.OAuth2.prototype._request= function(method, url, headers, post_body, access_token, callback) {
+ var http_library= https;
var creds = crypto.createCredentials({ });
var parsedUrl= URL.parse( url, true );
if( parsedUrl.protocol == "https:" && !parsedUrl.port ) {
parsedUrl.port= 443;
- http_library = https;
- } else {
- http_library = http;
+ }
+
+ // As this is OAUth2, we *assume* https unless told explicitly otherwise.
+ if( parsedUrl.protocol != "https:" ) {
+ http_library= http;
}
var realHeaders= {};

0 comments on commit ef51782

Please sign in to comment.