Explorar o código

add not found

itizawa %!s(int64=5) %!d(string=hai) anos
pai
achega
2a620f29ff
Modificáronse 2 ficheiros con 6 adicións e 1 borrados
  1. 1 1
      src/server/routes/index.js
  2. 5 0
      src/server/routes/page.js

+ 1 - 1
src/server/routes/index.js

@@ -180,7 +180,7 @@ module.exports = function(crowi, app) {
   app.post('/_api/hackmd.discard'        , accessTokenParser , loginRequiredStrictly , csrf, hackmd.validateForApi, hackmd.discard);
   app.post('/_api/hackmd.saveOnHackmd'   , accessTokenParser , loginRequiredStrictly , csrf, hackmd.validateForApi, hackmd.saveOnHackmd);
 
-  app.get('/share/:link', page.showSharePage);
+  app.get('/share/:link', page.showSharePage, page.notFound);
 
   app.get('/*/$'                   , loginRequired , page.showPageWithEndOfSlash, page.notFound);
   app.get('/*'                     , loginRequired , page.showPage, page.notFound);

+ 5 - 0
src/server/routes/page.js

@@ -448,6 +448,11 @@ module.exports = function(crowi, app) {
     // TODO find page by link
     const page = {};
 
+    if (page == null) {
+      // page is not found
+      return next();
+    }
+
     const renderVars = {};
 
     addRendarVarsForPage(renderVars, page);