utils/spdx: correctly detect non-deprecated licenses with plus

This commit is contained in:
Kenneth Chew 2021-02-23 16:28:24 -05:00
parent 3efab3efa7
commit edead95768
No known key found for this signature in database
GPG Key ID: BED0BEA07E06CA6C
2 changed files with 9 additions and 0 deletions

View File

@ -132,10 +132,18 @@ describe SPDX do
expect(described_class.deprecated_license?("GPL-1.0")).to eq true
end
it "returns true for deprecated license identifier with plus" do
expect(described_class.deprecated_license?("GPL-1.0+")).to eq true
end
it "returns false for non-deprecated license identifier" do
expect(described_class.deprecated_license?("MIT")).to eq false
end
it "returns false for non-deprecated license identifier with plus" do
expect(described_class.deprecated_license?("EPL-1.0+")).to eq false
end
it "returns false for invalid license identifier" do
expect(described_class.deprecated_license?("foo")).to eq false
end

View File

@ -78,6 +78,7 @@ module SPDX
return false if ALLOWED_LICENSE_SYMBOLS.include? license
return false unless valid_license?(license)
license = license.delete_suffix "+"
license_data["licenses"].none? do |spdx_license|
spdx_license["licenseId"] == license && !spdx_license["isDeprecatedLicenseId"]
end