mirror of https://gitee.com/bigwinds/arangodb
Fix Windows file path resolution
This commit is contained in:
parent
8686b4eadb
commit
a854cbf674
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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}"`);
|
||||
|
|
Loading…
Reference in New Issue