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

Commit

Permalink
Merge pull request #7 from daBeuh/fx-windows-path
Browse files Browse the repository at this point in the history
fixed path resolution on windows
  • Loading branch information
malko committed Jul 10, 2015
2 parents 1255dba + d918cf4 commit 9488ce5
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function use(app, CLIOPTS, config) {
port = undefined,
basename = undefined,
method = undefined;
var fullPath = file.replace(/^([^:]+):(\d+)\//, function (m, h, p) {
var fullPath = file.replace(/^([^\/]+)-(\d+)[\/\\]/, function (m, h, p) {
host = h, method;
port = p;
return '';
Expand Down
6 changes: 3 additions & 3 deletions dist/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var PROXYBACKUPREMOVEDHEADERS = [
];

var HELP_MESSAGE = function HELP_MESSAGE(exitCode) {
console.log('Stuback is a proxy server to ease api development.\n\nYou can use Automatic proxy configuration at http://localhost:port/proxy.pac\n\nUsage:\nstuback [options] --stubs stubRootDir\nwhere stubRootDir arguments is the root directory to store your stubs.\ne.g.\nstuback -p 3000 -c stuback.js ./stubs\n\nCheck the documentation at https://github.com/stuback for more info about the config file.\n\nOptions:\n-c, --config config file to use default to USERDIR/.stuback.js\n will create one if none exists\n-p, --port port to bind stuback on default to 3000\n-s, --stubs root directory of your stubs files (required)\n\nFlags:\n-h, --help display this help\n-v, --verbose turn on verbosity\n-l, --local by default server accept request directed to any address\n adding this flag will make the server accept request for 127.0.0.1 only\n');
console.log('Stuback is a proxy server to ease api development.\n\nYou can use Automatic proxy configuration at http://localhost:port/proxy.pac\n\nUsage:\nstuback [options] --stubs stubRootDir\nwhere stubRootDir arguments is the root directory to store your stubs.\ne.g.\nstuback -p 3000 -c stuback.js -s ./stubs\n\nCheck the documentation at https://github.com/stuback for more info about the config file.\n\nOptions:\n-c, --config config file to use default to USERDIR/.stuback.js\n will create one if none exists\n-p, --port port to bind stuback on default to 3000\n-s, --stubs root directory of your stubs files (required)\n\nFlags:\n-h, --help display this help\n-v, --verbose turn on verbosity\n-l, --local by default server accept request directed to any address\n adding this flag will make the server accept request for 127.0.0.1 only\n');
process.exit(exitCode);
};

Expand Down Expand Up @@ -136,7 +136,7 @@ var config = new _config2['default'](configPath, CLIOPTS, function () {
* @param {*} options = {} contains the hostConfig options + some boolean values about the way the middleware should work (backedBy mainly)
*/
function proxyMiddleware(req, res, next) {
var options = arguments[3] === undefined ? {} : arguments[3];
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];

req.pause();
var hostConfig = options.hostConfig || {},
Expand Down Expand Up @@ -242,7 +242,7 @@ function proxyMiddleware(req, res, next) {
* @param {*} options = {} contains the hostConfig options + some boolean values about the way the middleware should work
*/
function stubMiddleware(req, res, next) {
var options = arguments[3] === undefined ? {} : arguments[3];
var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];

var stubFileName = _utils2['default'].getStubFileName(CLIOPTS.stubsPath, req),
hostConfig = options.hostConfig;
Expand Down
2 changes: 1 addition & 1 deletion dist/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function getStubFileName(stubsPath, req) {
var port = parsedUrl.port || 80;
var pathname = _path2['default'].dirname(parsedUrl.pathname);
var filename = parsedUrl.path.substring(pathname.length).replace(/^\//, '');
return _path2['default'].normalize(stubsPath + '/' + hostname + ':' + port + '/' + cleanPath(pathname, true) + '/') + req.method.toLowerCase() + '-' + cleanPath(filename, true) + (req.params ? hashParams(req.params) : '');
return _path2['default'].normalize(stubsPath + '/' + hostname + '-' + port + '/' + cleanPath(pathname, true) + '/') + req.method.toLowerCase() + '-' + cleanPath(filename, true) + (req.params ? hashParams(req.params) : '');
}

function normalizeHostConfig(hostConfig) {
Expand Down
2 changes: 1 addition & 1 deletion src/admin.es6
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function use(app, CLIOPTS, config) {
function parseStubPath(stubPath) {
let file = stubPath.slice(CLIOPTS.stubsPath.length);
let host, port, basename, method;
let fullPath = file.replace(/^([^:]+):(\d+)\//, (m, h, p) => {
let fullPath = file.replace(/^([^\/]+)-(\d+)[\/\\]/, (m, h, p) => {
host = h, method;
port = p;
return '';
Expand Down
2 changes: 1 addition & 1 deletion src/server.es6
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Usage:
stuback [options] --stubs stubRootDir
where stubRootDir arguments is the root directory to store your stubs.
e.g.
stuback -p 3000 -c stuback.js ./stubs
stuback -p 3000 -c stuback.js -s ./stubs
Check the documentation at https://github.com/stuback for more info about the config file.
Expand Down
2 changes: 1 addition & 1 deletion src/utils.es6
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function getStubFileName(stubsPath, req) {
let port = parsedUrl.port || 80;
let pathname = path.dirname(parsedUrl.pathname);
let filename = parsedUrl.path.substring(pathname.length).replace(/^\//, '');
return path.normalize(stubsPath + '/' + hostname + ':' + port + '/' + cleanPath(pathname, true) + '/') +
return path.normalize(stubsPath + '/' + hostname + '-' + port + '/' + cleanPath(pathname, true) + '/') +
req.method.toLowerCase() + '-' + cleanPath(filename, true) +
(req.params ? hashParams(req.params) : '')
;
Expand Down

0 comments on commit 9488ce5

Please sign in to comment.