Fix license URL vs identifier precedence issue in AdditionalInfo component #2724
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Issue
This PR addresses the issue , where the
AdditionalInfo
component prioritizes the license identifier (SPDX) over the provided license URL. According to the OpenAPI specification, the url and identifier fields in the license object are mutually exclusive, meaning that if both are provided, thelicense.url
should take precedence.Suggested Fix
I updated the logic in the
AdditionalInfo
component to make sure that if alicense.url
is provided, it takes precedence over thelicense.identifier
. In the case where only an identifier is available, the component falls back to using the SPDX license URL.Following is the change to the license URL logic:
Unit Tests
The existing test already covers rendering the component when only the
license.url
is present. So, I added unit tests to cover the other two cases:license.url
when bothlicense.url
andlicense.identifier
are present.license.identifier
is provided.Storybook Changes
I also updated the Storybook stories to reflect this change, making the story names more meaningful:
license.url
is provided.license.identifier
is provided.license.url
when both URL and identifier are provided, with the URL taking precedence.Testing
I followed the contribution guidelines and did the following tests:
yarn elements-core test
. (screenshot 1)yarn elements-core storybook
to verify the visual output and behavior of the component. (screenshot 2)Both tests passed, and the issue seems to be resolved. I tested using Node v18.20.4 and v20.18.0.