فهرست منبع

remove parent path

itizawa 5 سال پیش
والد
کامیت
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 { format } from 'date-fns';
 import urljoin from 'url-join';
 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 { createSubscribedElement } from './UnstatedUtils';
 
 
 import AppContainer from '../services/AppContainer';
 import AppContainer from '../services/AppContainer';
@@ -22,16 +23,14 @@ const PageCreateModal = (props) => {
   const isReachable = config.isSearchServiceReachable;
   const isReachable = config.isSearchServiceReachable;
   const { path } = pageContainer.state;
   const { path } = pageContainer.state;
   const userPageRootPath = userPageRoot(appContainer.currentUser);
   const userPageRootPath = userPageRoot(appContainer.currentUser);
-  const parentPath = getParentPath(path);
+  const parentPath = pathUtils.addTrailingSlash(path);
   const now = format(new Date(), 'yyyy/MM/dd');
   const now = format(new Date(), 'yyyy/MM/dd');
 
 
   const [todayInput1, setTodayInput1] = useState(t('Memo'));
   const [todayInput1, setTodayInput1] = useState(t('Memo'));
   const [todayInput2, setTodayInput2] = useState('');
   const [todayInput2, setTodayInput2] = useState('');
   const [pageNameInput, setPageNameInput] = useState(parentPath);
   const [pageNameInput, setPageNameInput] = useState(parentPath);
   const [template, setTemplate] = useState(null);
   const [template, setTemplate] = useState(null);
-  const encodedPath = encodeURI(path);
-  console.log(path);
-  console.log(encodedPath);
+
   /**
   /**
    * change todayInput1
    * change todayInput1
    * @param {string} value
    * @param {string} value

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

@@ -47,27 +47,9 @@ const userPageRoot = (user) => {
   return `/user/${user.username}`;
   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 = {
 module.exports = {
   isTopPage,
   isTopPage,
   isTrashPage,
   isTrashPage,
   isUserPage,
   isUserPage,
   userPageRoot,
   userPageRoot,
-  getParentPath,
 };
 };