From 5332e877b2e9250cb604ba76c1d368b6c6ed5fa0 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Thu, 26 Nov 2020 10:32:55 -0500 Subject: [PATCH] livecheck: improve host string comparison --- Library/Homebrew/livecheck/livecheck.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/livecheck/livecheck.rb b/Library/Homebrew/livecheck/livecheck.rb index 0ce4a1d6e7..4ed490337b 100644 --- a/Library/Homebrew/livecheck/livecheck.rb +++ b/Library/Homebrew/livecheck/livecheck.rb @@ -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