mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
fix: validate that parameter names are unique (#7882)
This commit is contained in:
19
coderd/util/strings/strings.go
Normal file
19
coderd/util/strings/strings.go
Normal file
@ -0,0 +1,19 @@
|
||||
package strings
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// JoinWithConjunction joins a slice of strings with commas except for the last
|
||||
// two which are joined with "and".
|
||||
func JoinWithConjunction(s []string) string {
|
||||
last := len(s) - 1
|
||||
if last == 0 {
|
||||
return s[last]
|
||||
}
|
||||
return fmt.Sprintf("%s and %s",
|
||||
strings.Join(s[:last], ", "),
|
||||
s[last],
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user