Merge pull request #6742 from MikeMcQuaid/cask_loader_uri

cask_loader: fix URI detection.
This commit is contained in:
Mike McQuaid 2019-11-14 10:21:36 -08:00 committed by GitHub
commit 13a249a426
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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