BottleLoader: Fix installing a bottle from an URL

The name of the formula is not extracted correctly
when the URL includes a hyphen.
This commit is contained in:
Shaun Jackman 2017-06-09 11:44:25 -07:00
parent 054ed10cb1
commit 7dca9a13ee

View File

@ -108,7 +108,8 @@ module Formulary
case bottle_name
when %r{(https?|ftp|file)://}
# The name of the formula is found between the last slash and the last hyphen.
resource = Resource.new bottle_name[%r{([^/]+)-}, 1] { url bottle_name }
formula_name = File.basename(bottle_name)[/(.+)-/, 1]
resource = Resource.new(formula_name) { url bottle_name }
downloader = CurlBottleDownloadStrategy.new resource.name, resource
@bottle_filename = downloader.cached_location
cached = @bottle_filename.exist?