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';
|
'use strict';
|
||||||
|
|
||||||
var filepath, root, filename, encodedFilename;
|
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;
|
root = options.path;
|
||||||
|
|
||||||
if (options.root) {
|
if (options.root) {
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var joinPath = require('path').join;
|
var joinPath = require('path').join;
|
||||||
var resolvePath = require('path').resolve;
|
var normalizePath = require('path').normalize;
|
||||||
var internal = require('internal');
|
var internal = require('internal');
|
||||||
var ArangoError = require('@arangodb').ArangoError;
|
var ArangoError = require('@arangodb').ArangoError;
|
||||||
var errors = require('@arangodb').errors;
|
var errors = require('@arangodb').errors;
|
||||||
|
@ -97,7 +97,7 @@ function swaggerPath (path, basePath) {
|
||||||
if (!basePath) {
|
if (!basePath) {
|
||||||
basePath = joinPath(internal.startupPath, 'server', 'assets', 'swagger');
|
basePath = joinPath(internal.startupPath, 'server', 'assets', 'swagger');
|
||||||
}
|
}
|
||||||
path = resolvePath('/', path);
|
path = normalizePath('/' + path);
|
||||||
return joinPath(basePath, path);
|
return joinPath(basePath, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
const NotFound = require('http-errors').NotFound;
|
const NotFound = require('http-errors').NotFound;
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const joinPath = require('path').join;
|
const joinPath = require('path').join;
|
||||||
const resolvePath = require('path').resolve;
|
const normalizePath = require('path').normalize;
|
||||||
const internal = require('internal');
|
const internal = require('internal');
|
||||||
const errors = require('@arangodb').errors;
|
const errors = require('@arangodb').errors;
|
||||||
const FoxxManager = require('@arangodb/foxx/manager');
|
const FoxxManager = require('@arangodb/foxx/manager');
|
||||||
|
@ -102,7 +102,7 @@ module.exports = function createSwaggerRouteHandler (foxxMount, opts) {
|
||||||
} else if (path === 'index.html') {
|
} else if (path === 'index.html') {
|
||||||
path = indexFile;
|
path = indexFile;
|
||||||
}
|
}
|
||||||
path = resolvePath('/', path);
|
path = normalizePath('/' + path);
|
||||||
const filePath = joinPath(swaggerRoot, path);
|
const filePath = joinPath(swaggerRoot, path);
|
||||||
if (!fs.isFile(filePath)) {
|
if (!fs.isFile(filePath)) {
|
||||||
throw new NotFound(`unknown path "${req._raw.url}"`);
|
throw new NotFound(`unknown path "${req._raw.url}"`);
|
||||||
|
|
Loading…
Reference in New Issue