cask_loader: fix URI detection.

Fixes #6678
This commit is contained in:
Mike McQuaid 2019-11-14 07:38:24 -08:00
parent 1b926389ad
commit 5f07a1e9bf
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70

View File

@ -79,7 +79,13 @@ module Cask
class FromURILoader < FromPathLoader
def self.can_load?(ref)
uri_regex = ::URI::DEFAULT_PARSER.make_regexp
ref.to_s.match?(Regexp.new('\A' + uri_regex.source + '\Z', uri_regex.options))
return false unless ref.to_s.match?(Regexp.new('\A' + uri_regex.source + '\Z', uri_regex.options))
uri = URI(ref)
return false unless uri
return false unless uri.path
true
end
attr_reader :url