diff --git a/xeol/search/purl.go b/xeol/search/purl.go index 28933abf..26157c73 100644 --- a/xeol/search/purl.go +++ b/xeol/search/purl.go @@ -82,7 +82,12 @@ func normalizeSemver(version string) string { // Example: 5.0.20.5194 -> 5.0.20 // Example: 2.0.4.RELEASE -> 2.0.4 fourCompRe := regexp.MustCompile(`^(\d+\.\d+\.\d+)\.\w+`) - return fourCompRe.ReplaceAllString(version, "$1") + version = fourCompRe.ReplaceAllString(version, "$1") + + // Handle packages with tilde (~) characters + // Example: 1.23.3-1~bullseye + tildeRe := regexp.MustCompile(`^(\d+\.\d+\.\d+)-\d+~\w+`) + return tildeRe.ReplaceAllString(version, "$1") } func versionLength(version string) int { diff --git a/xeol/search/purl_test.go b/xeol/search/purl_test.go index a2a5fa16..2e663898 100644 --- a/xeol/search/purl_test.go +++ b/xeol/search/purl_test.go @@ -14,6 +14,10 @@ func TestNormalizeSemver(t *testing.T) { version string expected string }{ + { + version: "1.23.3-1~bullseye", + expected: "1.23.3", + }, { version: "2.0.4.RELEASE", expected: "2.0.4",