Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(license): fix license normalization for Universal Permissive License #7766

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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