Browse Source

fix: db pages can't have parent char

renaming a page to include '/' resulted in that page being
a name you couldn't type as '/' is reserved for parent/namespace
Gabriel Horner 1 year ago
parent
commit
aba8080271
1 changed files with 9 additions and 2 deletions
  1. 9 2
      deps/outliner/src/logseq/outliner/validate.cljs

+ 9 - 2
deps/outliner/src/logseq/outliner/validate.cljs

@@ -1,10 +1,11 @@
 (ns logseq.outliner.validate
 (ns logseq.outliner.validate
-  "Reusable validations from outliner level and above. Most validations throw
+  "Reusable DB graph validations for outliner level and above. Most validations throw
   errors so the user action stops immediately to display a notification"
   errors so the user action stops immediately to display a notification"
   (:require [clojure.string :as string]
   (:require [clojure.string :as string]
             [datascript.core :as d]
             [datascript.core :as d]
             [logseq.db :as ldb]
             [logseq.db :as ldb]
-            [logseq.common.date :as common-date]))
+            [logseq.common.date :as common-date]
+            [logseq.common.util.namespace :as ns-util]))
 
 
 (defn ^:api validate-page-title-characters
 (defn ^:api validate-page-title-characters
   "Validates characters that must not be in a page title"
   "Validates characters that must not be in a page title"
@@ -14,6 +15,12 @@
                     (merge meta-m
                     (merge meta-m
                            {:type :notification
                            {:type :notification
                             :payload {:message "Page name can't include \"#\"."
                             :payload {:message "Page name can't include \"#\"."
+                                      :type :warning}}))))
+  (when (string/includes? page-title ns-util/parent-char)
+    (throw (ex-info "Page name can't include \"/\"."
+                    (merge meta-m
+                           {:type :notification
+                            :payload {:message "Page name can't include \"/\"."
                                       :type :warning}})))))
                                       :type :warning}})))))
 
 
 (defn ^:api validate-page-title
 (defn ^:api validate-page-title