fix(pdf): incorrect file name for the browser

This commit is contained in:
charlie
2024-09-03 15:26:12 +08:00
parent a95b1bd0bf
commit 867672637c

View File

@@ -41,13 +41,16 @@
(defn inflate-asset
[original-path & {:keys [href]}]
(let [web-link? (string/starts-with? original-path "http")
blob-res? (some-> href (string/starts-with? "blob"))
filename (util/node-path.basename original-path)
ext-name (util/get-file-ext filename)
url (if (some-> href (string/starts-with? "blob")) href
url (if blob-res? href
(assets-handler/normalize-asset-resource-url original-path))
filename' (if web-link? filename (get-in-repo-assets-full-filename url))
filename' (some-> filename' (js/decodeURIComponent) (string/replace ' "/" "_"))
filekey (util/safe-sanitize-file-name (subs filename' 0 (- (count filename') (inc (count ext-name)))))]
filename' (if (or web-link? blob-res?) filename
(some-> (get-in-repo-assets-full-filename url)
(js/decodeURIComponent) (string/replace ' "/" "_")))
filekey (util/safe-sanitize-file-name
(subs filename' 0 (- (count filename') (inc (count ext-name)))))]
(when-let [key (and (not (string/blank? filekey))
(if web-link?
(str filekey "__" (hash url))