Steven Fukase 4 years ago
parent
commit
5eed15d5d3
2 changed files with 6 additions and 14 deletions
  1. 6 4
      src/client/js/components/PageCreateModal.jsx
  2. 0 10
      src/lib/util/path-utils.js

+ 6 - 4
src/client/js/components/PageCreateModal.jsx

@@ -8,7 +8,7 @@ import { withTranslation } from 'react-i18next';
 import { format } from 'date-fns';
 import { format } from 'date-fns';
 
 
 import {
 import {
-  userPageRoot, isCreatablePage, generateEditorPath,
+  userPageRoot, isCreatablePage,
 } from '@commons/util/path-utils';
 } from '@commons/util/path-utils';
 import { pathUtils } from 'growi-commons';
 import { pathUtils } from 'growi-commons';
 
 
@@ -77,14 +77,16 @@ const PageCreateModal = (props) => {
    * @param {string} paths
    * @param {string} paths
    */
    */
   function redirectToEditor(...paths) {
   function redirectToEditor(...paths) {
-    const joinedPath = [...paths].map(str => str.replace(/^\/+|\/+$|\s/g, '')).join('/');
+    // Remove trailing slashes
+    const joinedPath = [...paths].map(str => str.replace(/^\/+|\/+$|\s/g, '')).join('/').replace(/\/$/, '');
     try {
     try {
       const url = new URL(joinedPath, 'https://dummy');
       const url = new URL(joinedPath, 'https://dummy');
-      if (!isCreatablePage(url)) {
+      if (!isCreatablePage(url.pathname)) {
         toastError(new Error('Invalid characters'));
         toastError(new Error('Invalid characters'));
         return;
         return;
       }
       }
-      window.location.href = generateEditorPath(url.pathname);
+      // window.location.href = `${url.pathname}#edit`;
+      console.log(`${url.pathname}#edit`);
     }
     }
     catch (err) {
     catch (err) {
       toastError(new Error('Invalid path format'));
       toastError(new Error('Invalid path format'));

+ 0 - 10
src/lib/util/path-utils.js

@@ -69,15 +69,6 @@ const isCreatablePage = (path) => {
   return isCreatable;
   return isCreatable;
 };
 };
 
 
-/**
- * return path to editor
- * @param {string} path
- * @returns {string}
- */
-function generateEditorPath(path) {
-  return `${path}#edit`;
-}
-
 /**
 /**
  * return user path
  * return user path
  * @param {Object} user
  * @param {Object} user
@@ -125,7 +116,6 @@ module.exports = {
   isTrashPage,
   isTrashPage,
   isUserPage,
   isUserPage,
   isCreatablePage,
   isCreatablePage,
-  generateEditorPath,
   userPageRoot,
   userPageRoot,
   convertToNewAffiliationPath,
   convertToNewAffiliationPath,
   encodeSpaces,
   encodeSpaces,