itizawa 4 лет назад
Родитель
Сommit
f4f6e03324

+ 3 - 1
src/server/routes/apiv3/pages.js

@@ -6,8 +6,10 @@ const pathUtils = require('growi-commons').pathUtils;
 
 
 const { body } = require('express-validator');
 const { body } = require('express-validator');
 const { query } = require('express-validator');
 const { query } = require('express-validator');
+const { isCreatablePage } = require('@commons/util/path-utils');
 const ErrorV3 = require('../../models/vo/error-apiv3');
 const ErrorV3 = require('../../models/vo/error-apiv3');
 
 
+
 const router = express.Router();
 const router = express.Router();
 
 
 const LIMIT_FOR_LIST = 10;
 const LIMIT_FOR_LIST = 10;
@@ -378,7 +380,7 @@ module.exports = (crowi) => {
       socketClientId: +req.body.socketClientId || undefined,
       socketClientId: +req.body.socketClientId || undefined,
     };
     };
 
 
-    if (!Page.isCreatableName(newPagePath)) {
+    if (!isCreatablePage(newPagePath)) {
       return res.apiv3Err(new ErrorV3(`Could not use the path '${newPagePath})'`, 'invalid_path'), 409);
       return res.apiv3Err(new ErrorV3(`Could not use the path '${newPagePath})'`, 'invalid_path'), 409);
     }
     }
 
 

+ 2 - 3
src/server/routes/page.js

@@ -1,3 +1,4 @@
+const { isCreatablePage } = require('@commons/util/path-utils');
 const { serializePageSecurely } = require('../models/serializers/page-serializer');
 const { serializePageSecurely } = require('../models/serializers/page-serializer');
 const { serializeRevisionSecurely } = require('../models/serializers/revision-serializer');
 const { serializeRevisionSecurely } = require('../models/serializers/revision-serializer');
 const { serializeUserSecurely } = require('../models/serializers/user-serializer');
 const { serializeUserSecurely } = require('../models/serializers/user-serializer');
@@ -478,12 +479,10 @@ module.exports = function(crowi, app) {
   actions.notFound = async function(req, res) {
   actions.notFound = async function(req, res) {
     const path = getPathFromRequest(req);
     const path = getPathFromRequest(req);
 
 
-    const isCreatable = Page.isCreatableName(path);
-
     let view;
     let view;
     const renderVars = { path };
     const renderVars = { path };
 
 
-    if (!isCreatable) {
+    if (!isCreatablePage(path)) {
       view = 'layout-growi/not_creatable';
       view = 'layout-growi/not_creatable';
     }
     }
     else if (req.isForbidden) {
     else if (req.isForbidden) {

+ 3 - 1
src/server/util/createGrowiPagesFromImports.js

@@ -1,3 +1,5 @@
+const { isCreatablePage } = require('@commons/util/path-utils');
+
 module.exports = (crowi) => {
 module.exports = (crowi) => {
   const Page = crowi.model('Page');
   const Page = crowi.model('Page');
 
 
@@ -18,7 +20,7 @@ module.exports = (crowi) => {
       const path = page.path;
       const path = page.path;
       const user = page.user;
       const user = page.user;
       const body = page.body;
       const body = page.body;
-      const isCreatableName = await Page.isCreatableName(path);
+      const isCreatableName = isCreatablePage(path);
       const isPageNameTaken = await Page.findByPathAndViewer(path, user);
       const isPageNameTaken = await Page.findByPathAndViewer(path, user);
 
 
       if (isCreatableName && !isPageNameTaken) {
       if (isCreatableName && !isPageNameTaken) {