mirror of
https://github.com/adnanh/webhook.git
synced 2025-05-15 10:04:44 +00:00
Fix slice traversal in ExtractParameter
With these changes, I'm able to pass tests "a.1.b" and "a.1.b.c".
This commit is contained in:
parent
7635cfde33
commit
8a627f7e67
1 changed files with 3 additions and 3 deletions
|
@ -45,8 +45,8 @@ func ExtractParameter(s string, params interface{}) (string, bool) {
|
|||
if paramsValue := reflect.ValueOf(params); paramsValue.Kind() == reflect.Slice {
|
||||
if paramsValueSliceLength := paramsValue.Len(); paramsValueSliceLength > 0 {
|
||||
|
||||
if p := strings.SplitN(s, ".", 3); len(p) > 3 {
|
||||
index, err := strconv.ParseInt(p[1], 10, 64)
|
||||
if p := strings.SplitN(s, ".", 2); len(p) > 1 {
|
||||
index, err := strconv.ParseInt(p[0], 10, 64)
|
||||
|
||||
if err != nil {
|
||||
return "", false
|
||||
|
@ -54,7 +54,7 @@ func ExtractParameter(s string, params interface{}) (string, bool) {
|
|||
return "", false
|
||||
}
|
||||
|
||||
return ExtractParameter(p[2], params.([]map[string]interface{})[index])
|
||||
return ExtractParameter(p[1], params.([]interface{})[index])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue