mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
utils/spdx: do case insensitive comparison.
Various places that use SPDX licenses specify them as downcased strings so let's be more permissive in our comparisons/validations.
This commit is contained in:
parent
14fbd47808
commit
7173f1fb60
@ -87,7 +87,7 @@ module SPDX
|
||||
return ALLOWED_LICENSE_SYMBOLS.include? license if license.is_a? Symbol
|
||||
|
||||
license = license.delete_suffix "+"
|
||||
license_data["licenses"].any? { |spdx_license| spdx_license["licenseId"] == license }
|
||||
license_data["licenses"].any? { |spdx_license| spdx_license["licenseId"].downcase == license.downcase }
|
||||
end
|
||||
|
||||
sig { params(license: T.any(String, Symbol)).returns(T::Boolean) }
|
||||
@ -97,14 +97,14 @@ module SPDX
|
||||
|
||||
license = license.to_s.delete_suffix "+"
|
||||
license_data["licenses"].none? do |spdx_license|
|
||||
spdx_license["licenseId"] == license && !spdx_license["isDeprecatedLicenseId"]
|
||||
spdx_license["licenseId"].downcase == license.downcase && !spdx_license["isDeprecatedLicenseId"]
|
||||
end
|
||||
end
|
||||
|
||||
sig { params(exception: String).returns(T::Boolean) }
|
||||
def valid_license_exception?(exception)
|
||||
exception_data["exceptions"].any? do |spdx_exception|
|
||||
spdx_exception["licenseExceptionId"] == exception && !spdx_exception["isDeprecatedLicenseId"]
|
||||
spdx_exception["licenseExceptionId"].downcase == exception.downcase && !spdx_exception["isDeprecatedLicenseId"]
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user