fix: path/url joining bug on windows (#1064)

* fix error while using multiple level directory

* fix error while using non-english file name
This commit is contained in:
claneo 2018-10-25 14:25:10 +08:00 committed by Endilie Yacop Sucipto
parent 12fd204840
commit 8663a63e7d
2 changed files with 2 additions and 2 deletions

View file

@ -110,7 +110,7 @@ function execute(port) {
const app = express();
app.get(routing.docs(siteConfig.baseUrl), (req, res, next) => {
const url = req.path.toString().replace(siteConfig.baseUrl, '');
const url = decodeURI(req.path.toString().replace(siteConfig.baseUrl, ''));
const metadata =
Metadata[
Object.keys(Metadata).find(id => Metadata[id].permalink === url)

View file

@ -12,7 +12,7 @@ const path = require('path');
const escapeStringRegexp = require('escape-string-regexp');
function getSubDir(file, refDir) {
const subDir = path.dirname(path.relative(refDir, file)).replace('\\', '/');
const subDir = path.dirname(path.relative(refDir, file)).replace(/\\/g, '/');
return subDir !== '.' && !subDir.includes('..') ? subDir : null;
}