From cd8579948c7a2789f2f181ff39ee501ecd6464c7 Mon Sep 17 00:00:00 2001 From: Florian Dieminger Date: Thu, 11 Mar 2021 23:27:25 +0100 Subject: [PATCH] open editor for translated content (#3196) * open editor for translated content * fix parsing locale --- server/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/index.js b/server/index.js index 9ca695d1722f..4a4cf7f416ba 100644 --- a/server/index.js +++ b/server/index.js @@ -30,6 +30,7 @@ const fakeV1APIRouter = require("./fake-v1-api"); const { searchIndexRoute } = require("./search-index"); const flawsRoute = require("./flaws"); const { staticMiddlewares, originRequestMiddleware } = require("./middlewares"); +const { getRoot } = require("../content/utils"); async function buildDocumentFromURL(url) { const document = Document.findByURL(url); @@ -107,7 +108,9 @@ app.get("/_open", (req, res) => { if (fs.existsSync(filepath)) { absoluteFilepath = filepath; } else { - absoluteFilepath = path.join(CONTENT_ROOT, filepath); + const [locale] = filepath.split(path.sep); + const root = getRoot(locale); + absoluteFilepath = path.join(root, filepath); } // Double-check that the file can be found.