mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
🐛 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:
parent
735877756d
commit
32a1de9fe8
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user