-
Notifications
You must be signed in to change notification settings - Fork 14
Allow hsh_to_spdx to accept rightsUri as well as rightsURI. #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…was already doing that around line 1309
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes inconsistent handling of the "rightsUri" field in the hsh_to_spdx method by accepting both "rightsUri" and "rightsURI" variations. The change addresses a failing test in Lupo by ensuring the method can handle both camelCase and PascalCase variations of the rights URI field name.
Key Changes
- Modified the license lookup logic to check for both "rightsUri" and "rightsURI" field names
| def hsh_to_spdx(hsh) | ||
| spdx = resource_json(:spdx).fetch("licenses") | ||
| license = spdx.find { |l| l["licenseId"].casecmp?(hsh["rightsIdentifier"]) || l["seeAlso"].first == normalize_cc_url(hsh["rightsURI"]) || l["name"] == hsh["rights"] || l["seeAlso"].first == normalize_cc_url(hsh["rights"]) } | ||
| license = spdx.find { |l| l["licenseId"].casecmp?(hsh["rightsIdentifier"]) || l["seeAlso"].first == normalize_cc_url(hsh["rightsUri"]) || l["seeAlso"].first == normalize_cc_url(hsh["rightsURI"]) || l["name"] == hsh["rights"] || l["seeAlso"].first == normalize_cc_url(hsh["rights"]) } |
Copilot
AI
Jul 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expression l["seeAlso"].first is called three times in this condition chain. Consider extracting it to a variable to avoid repeated array access and potential nil errors if seeAlso is empty.
| license = spdx.find { |l| l["licenseId"].casecmp?(hsh["rightsIdentifier"]) || l["seeAlso"].first == normalize_cc_url(hsh["rightsUri"]) || l["seeAlso"].first == normalize_cc_url(hsh["rightsURI"]) || l["name"] == hsh["rights"] || l["seeAlso"].first == normalize_cc_url(hsh["rights"]) } | |
| license = spdx.find do |l| | |
| see_also_first = l["seeAlso"].first | |
| l["licenseId"].casecmp?(hsh["rightsIdentifier"]) || | |
| see_also_first == normalize_cc_url(hsh["rightsUri"]) || | |
| see_also_first == normalize_cc_url(hsh["rightsURI"]) || | |
| l["name"] == hsh["rights"] || | |
| see_also_first == normalize_cc_url(hsh["rights"]) | |
| end |
|
@svogt0511 and @codycooperross This looks pretty much complete. Should we update it and get it out soon? |
|
Not sure I remember what this is addressing, but feel free, @svogt0511 |
Note: hsh_to_spdx was was already implementing that behavior that around line 1309 of lib/bolognese/utils.rb.
Purpose
related to : https://github.com/orgs/datacite/projects/28/views/21?pane=issue&itemId=111924271&issue=datacite%7Cproduct-backlog%7C335
Approach
It fixes a failing test in lupo.
Open Questions and Pre-Merge TODOs
Learning
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Reviewer, please remember our guidelines: