mirror of
https://github.com/anchore/syft.git
synced 2026-11-05 00:46:38 +01:00
3122 valid license url characters (#3449)
* chore: strip unwanted characters from license URL --------- Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
This commit is contained in:
@@ -226,3 +226,39 @@ func TestLicense_Merge(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLicenseConstructors(t *testing.T) {
|
||||
type input struct {
|
||||
value string
|
||||
urls []string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
input input
|
||||
expected License
|
||||
}{
|
||||
{
|
||||
name: "License URLs are stripped of newlines and tabs",
|
||||
input: input{
|
||||
value: "New BSD License",
|
||||
urls: []string{
|
||||
`
|
||||
http://user-agent-utils.googlecode.com/svn/trunk/UserAgentUtils/LICENSE.txt
|
||||
|
||||
`},
|
||||
},
|
||||
expected: License{
|
||||
Value: "New BSD License",
|
||||
Type: license.Declared,
|
||||
URLs: []string{"http://user-agent-utils.googlecode.com/svn/trunk/UserAgentUtils/LICENSE.txt"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got := NewLicenseFromURLs(test.input.value, test.input.urls...)
|
||||
assert.Equal(t, test.expected, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user