1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 13:29:41 +02:00

fix(validate): refactor validate functions [BE-11574] (#683)

This commit is contained in:
Devon Steenberg 2025-04-24 08:59:44 +12:00 committed by GitHub
parent 1a3df54c04
commit 4e4fd5a4b4
2 changed files with 25 additions and 39 deletions

View file

@ -17,6 +17,11 @@ func Test_IsURL(t *testing.T) {
url: "https://google.com",
expectedResult: true,
},
{
name: "empty",
url: "",
expectedResult: false,
},
{
name: "no schema",
url: "google.com",
@ -33,9 +38,14 @@ func Test_IsURL(t *testing.T) {
expectedResult: true,
},
{
name: "invalid",
name: "no top level domain",
url: "google",
expectedResult: false,
expectedResult: true,
},
{
name: "Unicode URL",
url: "www.xn--exampe-7db.ai",
expectedResult: true,
},
}
@ -145,6 +155,11 @@ func Test_HasWhitespaceOnly(t *testing.T) {
s: "something like this",
expectedResult: false,
},
{
name: "all whitespace",
s: "\t\n\v\f\r ",
expectedResult: true,
},
}
for _, tc := range testCases {