Browse files

Updated the method for checking https vs http.

  • Loading branch information...
1 parent 9a32c3d commit b8f664e0739352dc9c92455c0757cd04215c56d2 @bnoguchi committed Jul 14, 2011
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/utils.js
View
8 lib/utils.js
@@ -1,3 +1,5 @@
+tls = require('tls');
+
var clone = exports.clone = function clone (obj) {
if (obj === undefined || obj === null)
return obj
@@ -24,9 +26,9 @@ function cloneArray (arr) {
exports.extractHostname = function (req) {
var headers = req.headers
- , protocol = req.connection.server.constructor.name === 'HTTPServer'
- ? 'http://'
- : 'https://' // === 'HTTPSServer'
+ , protocol = req.connection.server instanceof tls.Server
+ ? 'https://'
+ : 'http://'
, host = headers.host;
return protocol + host;
};

0 comments on commit b8f664e

Please sign in to comment.