diff --git a/app/frontend.js b/app/frontend.js index 4c500715536e6ab8834b8ca7454d1a5c6a491ce3..d54c3fb55b5242843214c58ea294f310709d7906 100644 --- a/app/frontend.js +++ b/app/frontend.js @@ -56,16 +56,22 @@ app.use((req, res) => { const [, categoryKey, algorithmKey] = url.parse(req.originalUrl).pathname.split('/'); let { title, description } = packageJson; - const algorithm = hierarchy.find(categoryKey, algorithmKey); - if (algorithm) { - title = [algorithm.categoryName, algorithm.algorithmName].join(' - '); - description = algorithm.description; + let algorithm = undefined; + if (categoryKey && categoryKey !== 'scratch-paper') { + algorithm = hierarchy.find(categoryKey, algorithmKey) || null; + if (algorithm) { + title = [algorithm.categoryName, algorithm.algorithmName].join(' - '); + description = algorithm.description; + } else { + res.status(404); + } } const indexFile = res.indexFile .replace(/\$TITLE/g, title) .replace(/\$DESCRIPTION/g, description) - .replace(/\$ALGORITHM/g, algorithm ? JSON.stringify(algorithm).replace(/ this.props.setAlgorithm(algorithm));