|
@@ -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'));
|