livecheck: improve host string comparison

This commit is contained in:
Sam Ford 2020-11-26 10:32:55 -05:00
parent d07590442c
commit 5332e877b2
No known key found for this signature in database
GPG Key ID: 95209E46C7FFDEFE

View File

@ -324,21 +324,21 @@ module Homebrew
path = uri.path.delete_prefix("/").delete_suffix(".git")
scheme = uri.scheme
if host == "github.com"
if host.end_with?("github.com")
return url if path.match? %r{/releases/latest/?$}
owner, repo = path.delete_prefix("downloads/").split("/")
url = "#{scheme}://#{host}/#{owner}/#{repo}.git"
elsif GITEA_INSTANCES.include? host
elsif host.end_with?(*GITEA_INSTANCES)
return url if path.match? %r{/releases/latest/?$}
owner, repo = path.split("/")
url = "#{scheme}://#{host}/#{owner}/#{repo}.git"
elsif GOGS_INSTANCES.include? host
elsif host.end_with?(*GOGS_INSTANCES)
owner, repo = path.split("/")
url = "#{scheme}://#{host}/#{owner}/#{repo}.git"
# sourcehut
elsif host == "git.sr.ht"
elsif host.end_with?("git.sr.ht")
owner, repo = path.split("/")
url = "#{scheme}://#{host}/#{owner}/#{repo}"
# gitlab