Skip to content

Commit

Permalink
Prevent lowercasing npm names to support grandfathered packages (#19)
Browse files Browse the repository at this point in the history
npm used to support package names
containing capital characters:
https://blog.npmjs.org/post/168978377570/new-package-moniker-rules.html

Such packages still exist on the npm
registry, like this one:
https://www.npmjs.com/package/Acid/v/3.0.17
  • Loading branch information
pmalmsten authored Oct 28, 2022
1 parent e93983a commit 810a771
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/PackageUrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private string ValidateName(string name)
}
return Type switch
{
"nuget" or "cocoapods" or "cpan" or "vsm" or "cran" => name,
"nuget" or "cocoapods" or "cpan" or "vsm" or "cran" or "npm" => name,
"pypi" => name.Replace('_', '-').ToLower(),
_ => name.ToLower()
};
Expand Down
12 changes: 12 additions & 0 deletions tests/TestAssets/test-suite-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@
"subpath": null,
"is_invalid": false
},
{
"description": "npm names are case sensitive (npm only requires lowercase names for new packages)",
"purl": "pkg:npm/[email protected]",
"canonical_purl": "pkg:npm/[email protected]",
"type": "npm",
"namespace": null,
"name": "Acid",
"version": "3.0.17",
"qualifiers": null,
"subpath": null,
"is_invalid": false
},
{
"description": "nuget names are case sensitive",
"purl": "pkg:Nuget/[email protected]",
Expand Down

0 comments on commit 810a771

Please sign in to comment.