mirror of
https://github.com/thegeeklab/wp-plugin-go.git
synced 2024-11-22 00:20:38 +00:00
feat: add helper function to ensure string prefix (#39)
This commit is contained in:
parent
1e98790015
commit
88f785414f
@ -77,3 +77,16 @@ func RenderTrim(ctx context.Context, client http.Client, template string, playlo
|
|||||||
|
|
||||||
return strings.Trim(out, " \n"), err
|
return strings.Trim(out, " \n"), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddPrefix is a helper function to ensure a string has a defined prefix.
|
||||||
|
func AddPrefix(prefix, input string) string {
|
||||||
|
if strings.TrimSpace(input) == "" {
|
||||||
|
return input
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(input, prefix) {
|
||||||
|
return input
|
||||||
|
}
|
||||||
|
|
||||||
|
return prefix + input
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user