Merge pull request #15946 from samford/livecheck/preprocess_url-compare-with-uri-host

Livecheck#preprocess_url: compare with URI host
This commit is contained in:
Mike McQuaid 2023-09-04 17:23:22 -04:00 committed by GitHub
commit 51889e7a08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -561,25 +561,24 @@ module Homebrew
end
host = uri.host
domain = uri.domain
path = uri.path
return url if host.nil? || path.nil?
domain = host = "github.com" if host == "github.s3.amazonaws.com"
host = "github.com" if host == "github.s3.amazonaws.com"
path = path.delete_prefix("/").delete_suffix(".git")
scheme = uri.scheme
if domain == "github.com"
if host == "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?(domain)
elsif GITEA_INSTANCES.include?(host)
return url if path.match? %r{/releases/latest/?$}
owner, repo = path.split("/")
url = "#{scheme}://#{host}/#{owner}/#{repo}.git"
elsif GOGS_INSTANCES.include?(domain)
elsif GOGS_INSTANCES.include?(host)
owner, repo = path.split("/")
url = "#{scheme}://#{host}/#{owner}/#{repo}.git"
# sourcehut