Skip to content

Commit

Permalink
added QueryEscape udf
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed Dec 28, 2018
1 parent 4344772 commit d51a5cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion data/udf/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ func Register(aMap data.Map) {
aMap.Put("Len", Length)
aMap.Put("IndexOf", IndexOf)
aMap.Put("FormatTime", FormatTime)

aMap.Put("QueryEscape", QueryEscape)
}
8 changes: 8 additions & 0 deletions data/udf/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/viant/toolbox"
"github.com/viant/toolbox/data"
"net/url"
"strings"
)

Expand Down Expand Up @@ -95,3 +96,10 @@ func IndexOf(source interface{}, state data.Map) (interface{}, error) {
}
return -1, nil
}


//QueryEscape returns url escaped text
func QueryEscape(source interface{}, state data.Map) (interface{}, error) {
text := toolbox.AsString(source)
return url.QueryEscape(text), nil
}

0 comments on commit d51a5cc

Please sign in to comment.