mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
refactor: replace strings.Replace with strings.ReplaceAll (#15392)
strings.ReplaceAll(s, old, new) is a wrapper function for strings.Replace(s, old, new, -1). But strings.ReplaceAll is more readable and removes the hardcoded -1. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@@ -553,7 +553,7 @@ func expandPattern(pattern string) []string {
|
||||
if start != -1 && end != -1 && end > start {
|
||||
regexToRemove = base[start+1 : end]
|
||||
}
|
||||
pattern = strings.Replace(pattern, regexToRemove, "", -1)
|
||||
pattern = strings.ReplaceAll(pattern, regexToRemove, "")
|
||||
|
||||
// Simplify named fields that have limited options, e.g. (?P<foo>a|b|c) -> (<P<foo>.+)
|
||||
pattern = altFieldsGroupRe.ReplaceAllStringFunc(pattern, func(s string) string {
|
||||
@@ -767,7 +767,7 @@ func (d *OASDocument) CreateOperationIDs(context string) {
|
||||
// Space-split on non-words, title case everything, recombine
|
||||
opID := nonWordRe.ReplaceAllString(strings.ToLower(path), " ")
|
||||
opID = strings.Title(opID)
|
||||
opID = method + strings.Replace(opID, " ", "", -1)
|
||||
opID = method + strings.ReplaceAll(opID, " ", "")
|
||||
|
||||
// deduplicate operationIds. This is a safeguard, since generated IDs should
|
||||
// already be unique given our current path naming conventions.
|
||||
|
||||
Reference in New Issue
Block a user