Skip to content

Commit

Permalink
fix issue for merge option
Browse files Browse the repository at this point in the history
  • Loading branch information
door7302 committed Mar 19, 2024
1 parent 7c4a1a1 commit 936e007
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func StreamData(m string, s string, payload ...string) {

}

func advancedSplit(path string) []string {
func advancedSplit(path string, merge bool) []string {

if strings.Contains(path, "=") && strings.Contains(path, "[") {
var newPath string
Expand All @@ -118,7 +118,15 @@ func advancedSplit(path string) []string {
newPath += string(w)
}
}
return strings.Split(newPath, "£££")
lp := strings.Split(newPath, "£££")
if merge {
for i, v := range lp {
if strings.Contains(v, "=") {
lp[i] = re1.ReplaceAllString(v, "x")
}
}
}
return lp
}
return strings.Split(path, "/")
}
Expand Down Expand Up @@ -192,11 +200,8 @@ func parseXpath(xpath string, value string, merge bool) error {

key = make([]string, 0)

if merge {
xpath = re1.ReplaceAllString(xpath, "x")
}
StreamData(fmt.Sprintf("XPATH Extracted: %s", xpath), "OK")
lpath := advancedSplit(xpath)
lpath := advancedSplit(xpath, merge)
StreamData(fmt.Sprintf("XPATH Extracted: %s", strings.Join(lpath, "/")), "OK")

parent = root
for i, v := range lpath {
Expand Down

0 comments on commit 936e007

Please sign in to comment.