Browse Source

fix(windows): remove encoding assets protocol path

charlie 3 years ago
parent
commit
fccce48c6b
2 changed files with 3 additions and 21 deletions
  1. 1 17
      src/main/frontend/handler/assets.cljs
  2. 2 4
      src/main/frontend/handler/editor.cljs

+ 1 - 17
src/main/frontend/handler/assets.cljs

@@ -12,20 +12,6 @@
   (and (util/electron?)
   (and (util/electron?)
        (:assets/alias-enabled? @state/state)))
        (:assets/alias-enabled? @state/state)))
 
 
-(defn encode-to-protect-assets-schema-path
-  [schema-path]
-  (cond-> schema-path
-    (string? schema-path)
-    (->
-     (string/replace #"\\+" "/")
-     (string/replace ":/" "/logseq__colon/"))))
-
-(defn decode-protected-assets-schema-path
-  [schema-path]
-  (cond-> schema-path
-    (string? schema-path)
-    (string/replace "/logseq__colon/" ":/")))
-
 (defn clean-path-prefix
 (defn clean-path-prefix
   [path]
   [path]
   (when (string? path)
   (when (string? path)
@@ -86,9 +72,7 @@
                                                  (second (get-alias-by-name (second (re-find #"^@([^\/]+)" full-path')))))
                                                  (second (get-alias-by-name (second (re-find #"^@([^\/]+)" full-path')))))
                                             (vector full-path')))))]
                                             (vector full-path')))))]
 
 
-                    (str "assets://"
-                         (encode-to-protect-assets-schema-path
-                          (string/replace full-path' (str "@" (:name alias)) (:dir alias))))
+                    (str "assets://" (string/replace full-path' (str "@" (:name alias)) (:dir alias)))
 
 
                     (str (if has-schema? "" "file://")
                     (str (if has-schema? "" "file://")
                          (util/node-path.join graph-root full-path))))]
                          (util/node-path.join graph-root full-path))))]

+ 2 - 4
src/main/frontend/handler/editor.cljs

@@ -1421,8 +1421,7 @@
         (assets-handler/resolve-asset-real-path-url (state/get-current-repo) path)
         (assets-handler/resolve-asset-real-path-url (state/get-current-repo) path)
 
 
         (util/electron?)
         (util/electron?)
-        (str "assets://"
-             (assets-handler/encode-to-protect-assets-schema-path full-path))
+        (str "assets://" full-path)
 
 
         (mobile-util/native-platform?)
         (mobile-util/native-platform?)
         (mobile-util/convert-file-src full-path)
         (mobile-util/convert-file-src full-path)
@@ -1448,8 +1447,7 @@
     (save-block! repo block content)
     (save-block! repo block content)
     (when (and local? delete-local?)
     (when (and local? delete-local?)
       ;; FIXME: should be relative to current block page path
       ;; FIXME: should be relative to current block page path
-      (when-let [href (if (util/electron?)
-                        (assets-handler/decode-protected-assets-schema-path href)
+      (when-let [href (if (util/electron?) href
                         (second (re-find #"\((.+)\)$" full-text)))]
                         (second (re-find #"\((.+)\)$" full-text)))]
         (fs/unlink! repo
         (fs/unlink! repo
                     (config/get-repo-path
                     (config/get-repo-path