[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Commit

Permalink
Uniform controller path for posix and win32
Browse files Browse the repository at this point in the history
Normalize path separators in paths to nested controllers so that x-swagger-router: 'path/to/controller' resolves the same controller on operating systems with different path separators.
  • Loading branch information
Merlin-Taylor committed Nov 2, 2016
1 parent 2dd76b6 commit 88def59
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion middleware/swagger-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var fs = require('fs');
var mHelpers = require('./helpers');
var path = require('path');

var PATH_SEP_REGEX = new RegExp('\\' + path.sep, 'g');

var defaultOptions = {
controllers: {},
useStubs: false // Should we set this automatically based on process.env.NODE_ENV?
Expand Down Expand Up @@ -59,7 +61,7 @@ var getHandlerName = function (req) {
return handlerName;
};
var getFullQualifiedHandlerId = function(controller, handler) {
return controller + '_' + handler;
return controller.replace(PATH_SEP_REGEX, '/') + '_' + handler;
};
var handlerCacheFromDir = function (dirOrDirs) {
var handlerCache = {};
Expand Down

0 comments on commit 88def59

Please sign in to comment.