Skip to content

Fix npm license extraction for selected releases - #226

Open
k-charansai wants to merge 1 commit into
aboutcode-org:masterfrom
k-charansai:fix/npm-release-license-211
Open

k-charansai wants to merge 1 commit into
aboutcode-org:masterfrom
k-charansai:fix/npm-release-license-211

Conversation

@k-charansai

Copy link
Copy Markdown

In get_npm_data_from_purl, the license was always taken from the top-level npm registry data. This meant that packages with different licenses across releases could end up showing the wrong license.

Update the logic to check the selected version's license first, and use the package-level license as a fallback if the version-specific value is missing or null.

Add regression tests to verify that version-specific licenses are picked correctly and that the fallback works as expected.

Closes #211

@k-charansai
k-charansai force-pushed the fix/npm-release-license-211 branch from 2be4bc3 to 87b0ec7 Compare November 6, 2026 09:36
In get_npm_data_from_purl, declared_license was unconditionally set to the
top-level registry document's license, causing older or re-licensed package
versions to incorrectly inherit the package-level license.

Read declared_license from version.get('license') first, falling back to
the top-level license when absent or null. Add regression test covering
per-version license resolution and fallback behavior.

Closes aboutcode-org#211

Signed-off-by: k-charansai <kcharansai052@gmail.com>
@k-charansai
k-charansai force-pushed the fix/npm-release-license-211 branch from 87b0ec7 to 2bd5859 Compare November 6, 2026 09:43

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant