mirror of
https://github.com/docusealco/docuseal
synced 2026-11-06 23:12:33 -05:00
fix url download
This commit is contained in:
1 parent
146b37f8cd
commit
5032676bd2
1 file changed
+11
-10
+11
-10
@@ -8,19 +8,20 @@ module DownloadUtils
|
||||
module_function
|
||||
|
||||
def call(url)
|
||||
uri = Addressable::URI.parse(url)
|
||||
|
||||
if Docuseal.multitenant?
|
||||
raise UnableToDownload, "Error loading: #{uri.display_uri}. Only HTTPS is allowed." if uri.scheme != 'https'
|
||||
|
||||
if uri.host.in?(LOCALHOSTS)
|
||||
raise UnableToDownload, "Error loading: #{uri.display_uri}. Can't download from localhost."
|
||||
end
|
||||
uri = begin
|
||||
URI(url)
|
||||
rescue URI::Error
|
||||
Addressable::URI.parse(url).normalize
|
||||
end
|
||||
|
||||
resp = conn.get(uri.display_uri.to_s)
|
||||
if Docuseal.multitenant?
|
||||
raise UnableToDownload, "Error loading: #{uri}. Only HTTPS is allowed." if uri.scheme != 'https'
|
||||
raise UnableToDownload, "Error loading: #{uri}. Can't download from localhost." if uri.host.in?(LOCALHOSTS)
|
||||
end
|
||||
|
||||
raise UnableToDownload, "Error loading: #{uri.display_uri}" if resp.status >= 400
|
||||
resp = conn.get(uri)
|
||||
|
||||
raise UnableToDownload, "Error loading: #{uri}" if resp.status >= 400
|
||||
|
||||
resp
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user