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:
Christopher Angelo Phillips
2024-11-19 15:34:58 +00:00
committed by GitHub
parent e7b65c2c58
commit f4cad63da1
2 changed files with 60 additions and 2 deletions
+36
View File
@@ -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)
})
}
}