From 126590983b4861ec5cd841bc3c36a2672675bdcc Mon Sep 17 00:00:00 2001 From: Paul Mathews Date: Wed, 25 Sep 2024 08:59:43 +1000 Subject: [PATCH 1/2] npm names are case sensitive --- packageurl.go | 3 +-- packageurl_test.go | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packageurl.go b/packageurl.go index 0dd89a7..5177228 100644 --- a/packageurl.go +++ b/packageurl.go @@ -586,8 +586,7 @@ func typeAdjustName(purlType, name string, qualifiers Qualifiers) string { TypeComposer, TypeDebian, TypeGithub, - TypeGolang, - TypeNPM: + TypeGolang: return strings.ToLower(name) case TypePyPi: return strings.ToLower(strings.ReplaceAll(name, "_", "-")) diff --git a/packageurl_test.go b/packageurl_test.go index db4151b..6fa8c8d 100644 --- a/packageurl_test.go +++ b/packageurl_test.go @@ -528,11 +528,11 @@ func TestNormalize(t *testing.T) { }, { name: "known type name adjustments", input: packageurl.PackageURL{ - Type: "npm", + Type: "alpm", Name: "nAmE", }, want: packageurl.PackageURL{ - Type: "npm", + Type: "alpm", Name: "name", Qualifiers: packageurl.Qualifiers{}, }, From 680f68c60506674a3b81fb0cec566b7f60481ad2 Mon Sep 17 00:00:00 2001 From: Paul Mathews Date: Wed, 25 Sep 2024 09:56:03 +1000 Subject: [PATCH 2/2] Allow npm namespaces to be case-sensitive --- packageurl.go | 1 - packageurl_test.go | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packageurl.go b/packageurl.go index 5177228..c0d46fc 100644 --- a/packageurl.go +++ b/packageurl.go @@ -566,7 +566,6 @@ func typeAdjustNamespace(purlType, ns string) string { TypeDebian, TypeGithub, TypeGolang, - TypeNPM, TypeRPM, TypeQpkg: return strings.ToLower(ns) diff --git a/packageurl_test.go b/packageurl_test.go index 6fa8c8d..9624228 100644 --- a/packageurl_test.go +++ b/packageurl_test.go @@ -515,12 +515,12 @@ func TestNormalize(t *testing.T) { }, { name: "known type namespace adjustments", input: packageurl.PackageURL{ - Type: "npm", + Type: "apk", Namespace: "NaMeSpAcE", Name: "pkg", }, want: packageurl.PackageURL{ - Type: "npm", + Type: "apk", Namespace: "namespace", Name: "pkg", Qualifiers: packageurl.Qualifiers{},