1
0
Fork 0

Fix Windows file path resolution

This commit is contained in:
Alan Plum 2016-11-22 13:59:16 +01:00
parent 8686b4eadb
commit a854cbf674
No known key found for this signature in database
GPG Key ID: 8ED72A9A323B6EFD
3 changed files with 5 additions and 5 deletions

View File

@ -2018,7 +2018,7 @@ function pathHandler (req, res, options, next) {
'use strict';
var filepath, root, filename, encodedFilename;
filepath = req.suffix.length ? path.resolve(path.sep, ...req.suffix.map((part) => decodeURIComponent(part))) : '';
filepath = req.suffix.length ? path.normalize(['', ...req.suffix.map((part) => decodeURIComponent(part))].join(path.sep)) : '';
root = options.path;
if (options.root) {

View File

@ -25,7 +25,7 @@
var _ = require('lodash');
var fs = require('fs');
var joinPath = require('path').join;
var resolvePath = require('path').resolve;
var normalizePath = require('path').normalize;
var internal = require('internal');
var ArangoError = require('@arangodb').ArangoError;
var errors = require('@arangodb').errors;
@ -97,7 +97,7 @@ function swaggerPath (path, basePath) {
if (!basePath) {
basePath = joinPath(internal.startupPath, 'server', 'assets', 'swagger');
}
path = resolvePath('/', path);
path = normalizePath('/' + path);
return joinPath(basePath, path);
}

View File

@ -25,7 +25,7 @@
const NotFound = require('http-errors').NotFound;
const fs = require('fs');
const joinPath = require('path').join;
const resolvePath = require('path').resolve;
const normalizePath = require('path').normalize;
const internal = require('internal');
const errors = require('@arangodb').errors;
const FoxxManager = require('@arangodb/foxx/manager');
@ -102,7 +102,7 @@ module.exports = function createSwaggerRouteHandler (foxxMount, opts) {
} else if (path === 'index.html') {
path = indexFile;
}
path = resolvePath('/', path);
path = normalizePath('/' + path);
const filePath = joinPath(swaggerRoot, path);
if (!fs.isFile(filePath)) {
throw new NotFound(`unknown path "${req._raw.url}"`);