Change first and last character when it doesn't match
This commit is contained in:
parent
210dd08326
commit
3e68f1c505
|
@ -34,6 +34,12 @@ func templateCleanImageName(s string) string {
|
|||
newb[i] = '-'
|
||||
}
|
||||
}
|
||||
if !('a' <= newb[0] && newb[0] <= 'z') {
|
||||
newb[0] = 'a'
|
||||
}
|
||||
if newb[l-1] == '-' {
|
||||
newb[l-1] = 'a'
|
||||
}
|
||||
return string(newb)
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,16 @@ func Test_templateCleanImageName(t *testing.T) {
|
|||
expected: "abcde-012345v1-0-0",
|
||||
},
|
||||
{
|
||||
origName: "0123456789012345678901234567890123456789012345678901234567890123456789",
|
||||
expected: "012345678901234567890123456789012345678901234567890123456789012",
|
||||
origName: "a123456789012345678901234567890123456789012345678901234567890123456789",
|
||||
expected: "a12345678901234567890123456789012345678901234567890123456789012",
|
||||
},
|
||||
{
|
||||
origName: "01234567890123456789012345678901234567890123456789012345678901.",
|
||||
expected: "a1234567890123456789012345678901234567890123456789012345678901a",
|
||||
},
|
||||
{
|
||||
origName: "01234567890123456789012345678901234567890123456789012345678901-",
|
||||
expected: "a1234567890123456789012345678901234567890123456789012345678901a",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue