Add the url_encode filter (#50)
This commit is contained in:
parent
355c7f2be5
commit
c01fa5d162
|
@ -5,6 +5,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
@ -503,6 +504,5 @@ func filterUpper(ctx stick.Context, val stick.Value, args ...stick.Value) stick.
|
|||
}
|
||||
|
||||
func filterURLEncode(ctx stick.Context, val stick.Value, args ...stick.Value) stick.Value {
|
||||
// TODO: Implement Me
|
||||
return val
|
||||
return url.QueryEscape(stick.CoerceString(val))
|
||||
}
|
||||
|
|
|
@ -129,6 +129,7 @@ func TestFilters(t *testing.T) {
|
|||
return
|
||||
},
|
||||
},
|
||||
{"urlencode", func() stick.Value { return filterURLEncode(nil, "http://test.com/dude?sweet=33&1=2") }, "http%3A%2F%2Ftest.com%2Fdude%3Fsweet%3D33%261%3D2"},
|
||||
}
|
||||
for _, test := range tests {
|
||||
matches := false
|
||||
|
|
Reference in a new issue