Skip to content

Commit

Permalink
Implemented helper query string filter
Browse files Browse the repository at this point in the history
  • Loading branch information
grrlopes committed Aug 11, 2023
1 parent 1e692d8 commit ae311ba
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions helper/parsefilter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package helper

import "strings"

func ParseFilter(filter string) string {

trim := strings.TrimSpace(filter)

split := strings.Split(trim, " ")

join := strings.Join(split, "* AND ")

join += "* AND"

return token(join)
}

func token(data string) string {
phrase := data
suffix := " AND"

lastIndex := strings.LastIndex(phrase, suffix)

if lastIndex != -1 {
updatedPhrase := phrase[:lastIndex] + phrase[lastIndex+len(suffix):]
return updatedPhrase
}

return phrase
}

0 comments on commit ae311ba

Please sign in to comment.