itizawa 5 лет назад
Родитель
Сommit
384ddf9108
2 измененных файлов с 4 добавлено и 23 удалено
  1. 4 5
      src/client/js/components/PageCreateModal.jsx
  2. 0 18
      src/lib/util/path-utils.js

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

@@ -8,7 +8,8 @@ import { withTranslation } from 'react-i18next';
 import { format } from 'date-fns';
 import urljoin from 'url-join';
 
-import { userPageRoot, getParentPath } from '@commons/util/path-utils';
+import { userPageRoot } from '@commons/util/path-utils';
+import { pathUtils } from 'growi-commons';
 import { createSubscribedElement } from './UnstatedUtils';
 
 import AppContainer from '../services/AppContainer';
@@ -22,16 +23,14 @@ const PageCreateModal = (props) => {
   const isReachable = config.isSearchServiceReachable;
   const { path } = pageContainer.state;
   const userPageRootPath = userPageRoot(appContainer.currentUser);
-  const parentPath = getParentPath(path);
+  const parentPath = pathUtils.addTrailingSlash(path);
   const now = format(new Date(), 'yyyy/MM/dd');
 
   const [todayInput1, setTodayInput1] = useState(t('Memo'));
   const [todayInput2, setTodayInput2] = useState('');
   const [pageNameInput, setPageNameInput] = useState(parentPath);
   const [template, setTemplate] = useState(null);
-  const encodedPath = encodeURI(path);
-  console.log(path);
-  console.log(encodedPath);
+
   /**
    * change todayInput1
    * @param {string} value

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

@@ -47,27 +47,9 @@ const userPageRoot = (user) => {
   return `/user/${user.username}`;
 };
 
-/**
- * return parent path
- * @param {string} path
- * @returns {boolean}
- */
-const getParentPath = (path) => {
-  if (isTopPage(path)) {
-    return path;
-  }
-
-  if (path.match(/.+\/$/)) {
-    return path;
-  }
-
-  return `${path}/`;
-};
-
 module.exports = {
   isTopPage,
   isTrashPage,
   isUserPage,
   userPageRoot,
-  getParentPath,
 };