summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/license/management/repository.rb2
-rw-r--r--spec/license/management/report/v2_spec.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/license/management/repository.rb b/lib/license/management/repository.rb
index a478dd6..164653c 100644
--- a/lib/license/management/repository.rb
+++ b/lib/license/management/repository.rb
@@ -36,7 +36,7 @@ module License
{
'id' => data['licenseId'],
'name' => data['name'],
- 'url' => data['detailsUrl']
+ 'url' => data['seeAlso'][-1]
}
else
log_info("could not find license named `#{license.send(:short_name)}` in SPDX index")
diff --git a/spec/license/management/report/v2_spec.rb b/spec/license/management/report/v2_spec.rb
index 766c08d..85c6158 100644
--- a/spec/license/management/report/v2_spec.rb
+++ b/spec/license/management/report/v2_spec.rb
@@ -39,5 +39,13 @@ RSpec.describe License::Management::Report::V2 do
specify { expect(result[:licenses][0]['id']).to eq(spdx_id) }
end
end
+
+ context "when choosing an appropriate url for a license" do
+ subject { described_class.new([dependency]) }
+ let(:license) { LicenseFinder::License.new(short_name: 'MIT', matcher: LicenseFinder::License::NoneMatcher.new, url: nil) }
+ let(:dependency) { double(name: 'x', summary: '', description: '', homepage: '', licenses: [license]) }
+
+ specify { expect(subject.to_h[:licenses][0]['url']).to eql('https://opensource.org/licenses/MIT') }
+ end
end
end