From 88109b16c37315f9934979070640ce9139b44de0 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Mon, 4 Sep 2023 00:47:17 -0400 Subject: [PATCH] Livecheck#preprocess_url: compare with URI host We now have a `gitea` formula in homebrew/core and its `stable` URL uses a dl.gitea.com tarball. Since the URL's domain is gitea.com, livecheck tries to preprocess the URL into a `.git` URL but the resulting URL doesn't work because it's not a Git repository. Gitea repositories use gitea.com (with no subdomain), so `#preprocess_url` should be comparing the URI host (`dl.gitea.com`) instead of the domain (`gitea.com`). This change allows gitea.com repository URLs to continue to be preprocessed into a `.git` URL while dl.gitea.com URLs are left untouched. This makes the same change for the other domains, as they don't use a subdomain either. --- Library/Homebrew/livecheck/livecheck.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/livecheck/livecheck.rb b/Library/Homebrew/livecheck/livecheck.rb index 9a1bf3e225..87114521df 100644 --- a/Library/Homebrew/livecheck/livecheck.rb +++ b/Library/Homebrew/livecheck/livecheck.rb @@ -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