fix url download
This commit is contained in:
+11
-10
@@ -8,19 +8,20 @@ module DownloadUtils
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
def call(url)
|
def call(url)
|
||||||
uri = Addressable::URI.parse(url)
|
uri = begin
|
||||||
|
URI(url)
|
||||||
if Docuseal.multitenant?
|
rescue URI::Error
|
||||||
raise UnableToDownload, "Error loading: #{uri.display_uri}. Only HTTPS is allowed." if uri.scheme != 'https'
|
Addressable::URI.parse(url).normalize
|
||||||
|
|
||||||
if uri.host.in?(LOCALHOSTS)
|
|
||||||
raise UnableToDownload, "Error loading: #{uri.display_uri}. Can't download from localhost."
|
|
||||||
end
|
|
||||||
end
|
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
|
resp
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user