Steven Fukase %!s(int64=4) %!d(string=hai) anos
pai
achega
d914d9c483
Modificáronse 1 ficheiros con 12 adicións e 8 borrados
  1. 12 8
      src/client/js/components/PageCreateModal.jsx

+ 12 - 8
src/client/js/components/PageCreateModal.jsx

@@ -77,16 +77,20 @@ const PageCreateModal = (props) => {
    * @param {string} paths
    * @param {string} paths
    */
    */
   function redirectToEditor(...paths) {
   function redirectToEditor(...paths) {
-    // Remove trailing slashes
-    const joinedPath = [...paths].map(str => str.replace(/^\/+|\/+$|\s/g, '')).join('/').replace(/\/$/, '');
+
+    const joinedPath = [...paths]
+      .map(str => str.replace(/^\/+|\/+$|\s/g, ''))
+      .join('/')
+      .replace(/\/$/, '');
+
+    if (!isCreatablePage(joinedPath)) {
+      toastError(new Error('Invalid characters'));
+      return;
+    }
+
     try {
     try {
       const url = new URL(joinedPath, 'https://dummy');
       const url = new URL(joinedPath, 'https://dummy');
-      if (!isCreatablePage(url.pathname)) {
-        toastError(new Error('Invalid characters'));
-        return;
-      }
-      // window.location.href = `${url.pathname}#edit`;
-      console.log(`${url.pathname}#edit`);
+      window.location.href = `${url.pathname}#edit`;
     }
     }
     catch (err) {
     catch (err) {
       toastError(new Error('Invalid path format'));
       toastError(new Error('Invalid path format'));