浏览代码

fix: filename format revert manual title check

Junyi 2 年之前
父节点
当前提交
48445c9149
共有 2 个文件被更改,包括 15 次插入6 次删除
  1. 14 5
      src/main/frontend/handler/conversion.cljs
  2. 1 1
      src/test/frontend/db/name_sanity_test.cljs

+ 14 - 5
src/main/frontend/handler/conversion.cljs

@@ -59,8 +59,6 @@
 ;;   - the special rule in `is-manual-title-prop?`
 (defonce supported-filename-formats [:triple-lowbar :legacy])
 
-;; In case of recovering this check in future
-#_:clj-kondo/ignore
 (defn- is-manual-title-prop?
   "If it's an user defined title property instead of the generated one"
   [format file-body prop-title]
@@ -104,6 +102,17 @@
   [page path old-format new-format]
   (let [prop-title (get-in page [:block/properties :title])
         file-body  (gp-util/path->file-body path)
-        journal?   (:block/journal? page)]
-    (when (not journal?)
-      (calc-rename-target-impl old-format new-format file-body prop-title))))
+        journal?   (:block/journal? page)
+        manual-prop-title? (is-manual-title-prop? old-format file-body prop-title)]
+    (cond
+      (and (not journal?)
+           (not manual-prop-title?))
+      (calc-rename-target-impl old-format new-format file-body prop-title)
+
+      (and (not journal?)
+           manual-prop-title?
+           (fs-util/include-reserved-chars? file-body))
+      {:status        :informal
+       :target        (fs-util/file-name-sanity file-body new-format)
+       :old-title     prop-title
+       :changed-title prop-title})))

+ 1 - 1
src/test/frontend/db/name_sanity_test.cljs

@@ -74,7 +74,7 @@
     "aaa__bbb__cccon" "aaa/bbb/cccon"  true
     "aaa.bbb.ccc"     "adbcde/aks/sdf" true
     "a__.bbb.ccc"     "adbcde/aks/sdf" true
-    ))
+    "aaa__bbb__ccc" nil false))
 
 (deftest rename-previous-tests
   (are [x y] (= y (#'conversion-handler/calc-previous-name :legacy :triple-lowbar x))