Deal with potential chart name with that start with hyphen

From copilot review:
> The condition i > 0 will fail to split chart names that start with a hyphen followed by a version (e.g., "-chart-1.0.0" would return "-chart-1.0.0", "" instead of "-chart", "1.0.0"). This should be i >= 0 to handle edge cases correctly.

https://github.com/helm/helm/pull/31206#discussion_r2311950405

Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
pull/31206/head
Benoit Tigeot 4 weeks ago
parent e9cfefbf44
commit 311659c085
No known key found for this signature in database
GPG Key ID: 8E6D4FC8AEBDA62C

@ -214,7 +214,7 @@ func trimAnySuffix(s string, suffixes ...string) string {
}
func splitChartNameVersion(s string) (name, version string) {
if i := strings.LastIndex(s, "-"); i > 0 {
if i := strings.LastIndex(s, "-"); i >= 0 {
return s[:i], s[i+1:]
}
return s, ""

Loading…
Cancel
Save