mirror of https://github.com/logseq/logseq
fix: don't replace _ for the page name if it's not a local asset
parent
192a30ae1b
commit
b6be007d98
|
@ -261,11 +261,15 @@
|
|||
(defn fix-local-asset-filename
|
||||
[filename]
|
||||
(when-not (string/blank? filename)
|
||||
(let [local-asset? (re-find #"[0-9]{13}_\d$" filename)]
|
||||
(let [local-asset? (re-find #"[0-9]{13}_\d$" filename)
|
||||
hls? (and local-asset? (re-find #"^hls__" filename))]
|
||||
(if (or local-asset? hls?)
|
||||
(-> filename
|
||||
(subs 0 (- (count filename) (if local-asset? 15 0)))
|
||||
(subs 0 (- (count filename) 15))
|
||||
(string/replace #"^hls__" "")
|
||||
(string/replace "_" " ")))))
|
||||
(string/replace "_" " ")
|
||||
(string/trimr))
|
||||
filename))))
|
||||
|
||||
(rum/defc human-hls-filename-display
|
||||
[title]
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
(ns frontend.extensions.pdf.assets-test
|
||||
(:require [clojure.test :as test :refer [are deftest testing]]
|
||||
[clojure.string :as str]
|
||||
[frontend.extensions.pdf.assets :as assets]))
|
||||
|
||||
(deftest fix-local-asset-filename
|
||||
(testing "matched filenames"
|
||||
(are [x y] (= y (assets/fix-local-asset-filename x))
|
||||
"2015_Book_Intertwingled_1659920114630_0" "2015 Book Intertwingled"
|
||||
"hls__2015_Book_Intertwingled_1659920114630_0" "2015 Book Intertwingled"))
|
||||
(testing "non matched filenames"
|
||||
(are [x y] (= y (assets/fix-local-asset-filename x))
|
||||
"foo" "foo"
|
||||
"foo_bar" "foo_bar"
|
||||
"foo__bar" "foo__bar"
|
||||
"foo_bar.pdf" "foo_bar.pdf")))
|
Loading…
Reference in New Issue