Skip to content

Commit

Permalink
fix(license): fix license normalization for Universal Permissive Lice…
Browse files Browse the repository at this point in the history
…nse (#7766)
  • Loading branch information
pbaumard authored Oct 21, 2024
1 parent 57e24aa commit f6acdf7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/licensing/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ func TrimLicenseText(text string) string {
}

// version number match
var versionRegexpString = "([A-UW-Z)]{2,})( LICENSE)?\\s*[,(-]?\\s*(V|V\\.|VER|VER\\.|VERSION|VERSION-|-)?\\s*([1-9](\\.\\d)*)[)]?"
var versionRegexpString = "([A-UW-Z)])( LICENSE)?\\s*[,(-]?\\s*(V|V\\.|VER|VER\\.|VERSION|VERSION-|-)?\\s*([1-9](\\.\\d)*)[)]?"

// case insensitive version match anywhere in string
var versionRegexp = regexp.MustCompile("(?i)" + versionRegexpString)
Expand Down
7 changes: 7 additions & 0 deletions pkg/licensing/normalize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ func TestNormalize(t *testing.T) {
normalized: " The unmapped license ",
normalizedKey: " The unmapped license ",
},
{
licenses: []string{
"Universal Permissive License, Version 1.0",
},
normalized: "UPL-1.0",
normalizedKey: "UPL-1.0",
},
}
for _, tt := range tests {
t.Run(tt.normalized, func(t *testing.T) {
Expand Down

0 comments on commit f6acdf7

Please sign in to comment.