🐛 Filter non-http(s) URLs in upload-images to prevent invalid calls

Skip upload for image items that are not data URIs and do not have
an http:// or https:// URL, avoiding unnecessary RPC calls with
invalid URLs to create-file-media-object-from-url.

Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
Andrey Antukh 2026-04-22 22:05:13 +00:00
parent 735877756d
commit 32a1de9fe8

View File

@ -47,10 +47,12 @@
(-> item
(assoc :name (extract-name href))
(assoc :url href))))))
(rx/filter (fn [item]
(or (contains? item :content)
(let [url (:url item)]
(or (str/starts-with? url "http://")
(str/starts-with? url "https://"))))))
(rx/mapcat (fn [item]
;; TODO: :create-file-media-object-from-url is
;; deprecated and this should be resolved in
;; frontend
(->> (rp/cmd! (if (contains? item :content)
:upload-file-media-object
:create-file-media-object-from-url)