Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix for HTTPS in express 2.5.10

  • Loading branch information...
commit fc2f5872a815afd9d5b65398577f15658dca6ae1 1 parent a9a097f
@davidmurdoch davidmurdoch authored
Showing with 27 additions and 21 deletions.
  1. +27 −21 index.js
View
48 index.js
@@ -5,9 +5,9 @@
var express = require('express')
, methods = require('methods').concat('del')
- , app = express.application
- ? express.application
- : express.HTTPServer.prototype;
+ , apps = express.application
+ ? [express.application]
+ : [express.HTTPServer.prototype, express.HTTPSServer.prototype];
/**
* Namespace using the given `path`, providing a callback `fn()`,
@@ -19,7 +19,7 @@ var express = require('express')
* @api public
*/
-app.namespace = function(){
+var namespace = exports.namespace = function(){
var args = Array.prototype.slice.call(arguments)
, path = args.shift()
, fn = args.pop()
@@ -33,27 +33,33 @@ app.namespace = function(){
return this;
};
+apps.forEach(function(app){
+ app.namespace = namespace;
+});
+
/**
* Proxy HTTP methods to provide namespacing support.
*/
methods.forEach(function(method){
- var orig = app[method];
- app[method] = function(val){
- var len = arguments.length;
- if ('get' == method && 1 == len) return orig.call(this, val);
-
- var args = Array.prototype.slice.call(arguments)
- , path = args.shift()
- , self = this;
-
- this.namespace(path, function(){
- path = this._ns.join('/').replace(/\/\//g, '/').replace(/\/$/, '');
- args.forEach(function(fn){
- orig.call(self, path, fn);
+ apps.forEach(function(app){
+ var orig = app[method];
+ app[method] = function(val){
+ var len = arguments.length;
+ if ('get' == method && 1 == len) return orig.call(this, val);
+
+ var args = Array.prototype.slice.call(arguments)
+ , path = args.shift()
+ , self = this;
+
+ this.namespace(path, function(){
+ path = this._ns.join('/').replace(/\/\//g, '/').replace(/\/$/, '') || '/';
+ args.forEach(function(fn){
+ orig.call(self, path, fn);
+ });
});
- });
- return this;
- };
-});
+ return this;
+ };
+ });
+});

0 comments on commit fc2f587

Please sign in to comment.
Something went wrong with that request. Please try again.