match with url host instead of string

This commit is contained in:
Aaron Ruan 2024-05-27 00:26:35 +08:00
parent 7da9ea07d0
commit 73ead3e5f5
No known key found for this signature in database
GPG Key ID: EF612DB3936CDD62

View File

@ -328,8 +328,7 @@ module Cask
add_error "SourceForge URL format incorrect. See #{Formatter.url(SOURCEFORGE_OSDN_REFERENCE_URL)}", add_error "SourceForge URL format incorrect. See #{Formatter.url(SOURCEFORGE_OSDN_REFERENCE_URL)}",
location: cask.url.location location: cask.url.location
elsif bad_osdn_url? elsif bad_osdn_url?
add_error "OSDN URLs are disabled.", add_error "OSDN download urls are disabled.", location: cask.url.location, strict_only: true
location: cask.url.location
end end
end end
@ -895,7 +894,7 @@ module Cask
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def bad_osdn_url? def bad_osdn_url?
cask.url.to_s.match?(%r{^(?:https?://)?(?:\w+\.)*osdn\.jp(?=/|$)}) URI(cask.url.to_s).host.match?(%r{^(?:\w+\.)*osdn\.jp(?=/|$)})
end end
# sig { returns(String) } # sig { returns(String) }