Skip to content

Commit

Permalink
[minor_change] Removed reverseString function and logic from model ut…
Browse files Browse the repository at this point in the history
…ils.go
  • Loading branch information
sajagana authored and lhercot committed Sep 19, 2023
1 parent 2086a68 commit ca2de35
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions models/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,27 +99,17 @@ func GetMORnPrefix(DistinguishedName string) string {
if DistinguishedName != "" {
bracketIndex := 0
rnIndex := 0
reversedDistinguishedName := reverseString(DistinguishedName)
for i, v := range reversedDistinguishedName {
stringValue := string(v)
if stringValue == "]" {
for i := len(DistinguishedName) - 1; i >= 0; i-- {
if string(DistinguishedName[i]) == "]" {
bracketIndex = bracketIndex + 1
} else if stringValue == "[" {
} else if string(DistinguishedName[i]) == "[" {
bracketIndex = bracketIndex - 1
} else if stringValue == "/" && bracketIndex == 0 {
} else if string(DistinguishedName[i]) == "/" && bracketIndex == 0 {
rnIndex = i
break
}
}
return strings.Split(reverseString(reversedDistinguishedName[0:rnIndex]), "-")[0]
return strings.Split(string(DistinguishedName[rnIndex+1:]), "-")[0]
}
return DistinguishedName
}

func reverseString(s string) string {
reverse := ""
for i := len(s) - 1; i >= 0; i-- {
reverse += string(s[i])
}
return reverse
}

0 comments on commit ca2de35

Please sign in to comment.