Skip to content

Commit 1db185b

Browse files
authored
sanitize replacer on the formatKeyName funtion for runtimes configmap population (#653)
1 parent c843b25 commit 1db185b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

components/odh-notebook-controller/controllers/notebook_runtime.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"reflect"
7+
"regexp"
78
"strings"
89

910
"github.com/go-logr/logr"
@@ -182,9 +183,12 @@ func extractDisplayName(metadata string) string {
182183
return displayName
183184
}
184185

186+
var multiDash = regexp.MustCompile(`-+`)
187+
185188
func formatKeyName(displayName string) string {
186-
replacer := strings.NewReplacer(" ", "-", "(", "", ")", "")
187-
return strings.ToLower(replacer.Replace(displayName)) + ".json"
189+
s := strings.NewReplacer(" ", "-", "(", "", ")", "", "|", "").Replace(displayName)
190+
s = multiDash.ReplaceAllString(strings.ToLower(s), "-")
191+
return strings.Trim(s, "-") + ".json"
188192
}
189193

190194
// parseRuntimeImageMetadata extracts the first object from the JSON array

0 commit comments

Comments
 (0)