Rename base64enc/dec to encode/decode.
There isn't any precedent for abbreviating words in the interpolation function names, and it may not be clear to all users what "enc" and "dec" are short for, so instead we'll prefer to spell out the whole words for improved readability.
This commit is contained in:
parent
b4e0a8e225
commit
0b85d35e87
|
@ -20,18 +20,18 @@ var Funcs map[string]ast.Function
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Funcs = map[string]ast.Function{
|
Funcs = map[string]ast.Function{
|
||||||
"concat": interpolationFuncConcat(),
|
"concat": interpolationFuncConcat(),
|
||||||
"element": interpolationFuncElement(),
|
"element": interpolationFuncElement(),
|
||||||
"file": interpolationFuncFile(),
|
"file": interpolationFuncFile(),
|
||||||
"format": interpolationFuncFormat(),
|
"format": interpolationFuncFormat(),
|
||||||
"formatlist": interpolationFuncFormatList(),
|
"formatlist": interpolationFuncFormatList(),
|
||||||
"index": interpolationFuncIndex(),
|
"index": interpolationFuncIndex(),
|
||||||
"join": interpolationFuncJoin(),
|
"join": interpolationFuncJoin(),
|
||||||
"length": interpolationFuncLength(),
|
"length": interpolationFuncLength(),
|
||||||
"replace": interpolationFuncReplace(),
|
"replace": interpolationFuncReplace(),
|
||||||
"split": interpolationFuncSplit(),
|
"split": interpolationFuncSplit(),
|
||||||
"base64enc": interpolationFuncBase64Encode(),
|
"base64encode": interpolationFuncBase64Encode(),
|
||||||
"base64dec": interpolationFuncBase64Decode(),
|
"base64decode": interpolationFuncBase64Decode(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,8 +396,8 @@ func interpolationFuncValues(vs map[string]ast.Variable) ast.Function {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// interpolationFuncBase64Encode implements the "base64enc" function that allows
|
// interpolationFuncBase64Encode implements the "base64encode" function that
|
||||||
// Base64 encoding.
|
// allows Base64 encoding.
|
||||||
func interpolationFuncBase64Encode() ast.Function {
|
func interpolationFuncBase64Encode() ast.Function {
|
||||||
return ast.Function{
|
return ast.Function{
|
||||||
ArgTypes: []ast.Type{ast.TypeString},
|
ArgTypes: []ast.Type{ast.TypeString},
|
||||||
|
@ -409,8 +409,8 @@ func interpolationFuncBase64Encode() ast.Function {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// interpolationFuncBase64Decode implements the "base64dec" function that allows
|
// interpolationFuncBase64Decode implements the "base64decode" function that
|
||||||
// Base64 decoding.
|
// allows Base64 decoding.
|
||||||
func interpolationFuncBase64Decode() ast.Function {
|
func interpolationFuncBase64Decode() ast.Function {
|
||||||
return ast.Function{
|
return ast.Function{
|
||||||
ArgTypes: []ast.Type{ast.TypeString},
|
ArgTypes: []ast.Type{ast.TypeString},
|
||||||
|
|
|
@ -589,7 +589,7 @@ func TestInterpolateFuncBase64Encode(t *testing.T) {
|
||||||
Cases: []testFunctionCase{
|
Cases: []testFunctionCase{
|
||||||
// Regular base64 encoding
|
// Regular base64 encoding
|
||||||
{
|
{
|
||||||
`${base64enc("abc123!?$*&()'-=@~")}`,
|
`${base64encode("abc123!?$*&()'-=@~")}`,
|
||||||
"YWJjMTIzIT8kKiYoKSctPUB+",
|
"YWJjMTIzIT8kKiYoKSctPUB+",
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
@ -602,14 +602,14 @@ func TestInterpolateFuncBase64Decode(t *testing.T) {
|
||||||
Cases: []testFunctionCase{
|
Cases: []testFunctionCase{
|
||||||
// Regular base64 decoding
|
// Regular base64 decoding
|
||||||
{
|
{
|
||||||
`${base64dec("YWJjMTIzIT8kKiYoKSctPUB+")}`,
|
`${base64decode("YWJjMTIzIT8kKiYoKSctPUB+")}`,
|
||||||
"abc123!?$*&()'-=@~",
|
"abc123!?$*&()'-=@~",
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Invalid base64 data decoding
|
// Invalid base64 data decoding
|
||||||
{
|
{
|
||||||
`${base64dec("this-is-an-invalid-base64-data")}`,
|
`${base64decode("this-is-an-invalid-base64-data")}`,
|
||||||
nil,
|
nil,
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
|
|
@ -74,10 +74,10 @@ are documented below.
|
||||||
|
|
||||||
The supported built-in functions are:
|
The supported built-in functions are:
|
||||||
|
|
||||||
* `base64dec(string)` - Given a base64-encoded string, decodes it and
|
* `base64decode(string)` - Given a base64-encoded string, decodes it and
|
||||||
returns the original string.
|
returns the original string.
|
||||||
|
|
||||||
* `base64enc(string)` - Returns a base64-encoded representation of the
|
* `base64encode(string)` - Returns a base64-encoded representation of the
|
||||||
given string.
|
given string.
|
||||||
|
|
||||||
* `concat(list1, list2)` - Combines two or more lists into a single list.
|
* `concat(list1, list2)` - Combines two or more lists into a single list.
|
||||||
|
|
Loading…
Reference in New Issue