mirror of
https://github.com/thegeeklab/wp-matrix.git
synced 2024-11-24 03:20:38 +00:00
17 lines
307 B
Go
17 lines
307 B
Go
package matrix
|
|
|
|
import "strings"
|
|
|
|
// EnsurePrefix ensures that the given input string starts with the provided prefix.
|
|
func EnsurePrefix(prefix, input string) string {
|
|
if strings.TrimSpace(input) == "" {
|
|
return input
|
|
}
|
|
|
|
if strings.HasPrefix(input, prefix) {
|
|
return input
|
|
}
|
|
|
|
return prefix + input
|
|
}
|