mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
aee2b06780
commit
55d0b89417
2 changed files with 11 additions and 1 deletions
|
@ -53,6 +53,7 @@ func (ns *Namespace) checkCondition(v, mv reflect.Value, op string) (bool, error
|
||||||
if !v.IsValid() {
|
if !v.IsValid() {
|
||||||
vIsNil = true
|
vIsNil = true
|
||||||
}
|
}
|
||||||
|
|
||||||
mv, mvIsNil := indirect(mv)
|
mv, mvIsNil := indirect(mv)
|
||||||
if !mv.IsValid() {
|
if !mv.IsValid() {
|
||||||
mvIsNil = true
|
mvIsNil = true
|
||||||
|
@ -115,7 +116,7 @@ func (ns *Namespace) checkCondition(v, mv reflect.Value, op string) (bool, error
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.Kind() != reflect.Interface && mv.Type().Elem().Kind() != reflect.Interface && mv.Type().Elem() != v.Type() {
|
if v.Kind() != reflect.Interface && mv.Type().Elem().Kind() != reflect.Interface && mv.Type().Elem() != v.Type() && v.Kind() != reflect.Array && v.Kind() != reflect.Slice {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
switch v.Kind() {
|
switch v.Kind() {
|
||||||
|
@ -144,6 +145,9 @@ func (ns *Namespace) checkCondition(v, mv reflect.Value, op string) (bool, error
|
||||||
ima = append(ima, toTimeUnix(mv.Index(i)))
|
ima = append(ima, toTimeUnix(mv.Index(i)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case reflect.Array, reflect.Slice:
|
||||||
|
slv = v.Interface()
|
||||||
|
slmv = mv.Interface()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -536,6 +536,12 @@ func TestCheckCondition(t *testing.T) {
|
||||||
{reflect.ValueOf(true), reflect.ValueOf(false), ">", expect{false, false}},
|
{reflect.ValueOf(true), reflect.ValueOf(false), ">", expect{false, false}},
|
||||||
{reflect.ValueOf(123), reflect.ValueOf([]int{}), "in", expect{false, false}},
|
{reflect.ValueOf(123), reflect.ValueOf([]int{}), "in", expect{false, false}},
|
||||||
{reflect.ValueOf(123), reflect.ValueOf(123), "op", expect{false, true}},
|
{reflect.ValueOf(123), reflect.ValueOf(123), "op", expect{false, true}},
|
||||||
|
|
||||||
|
// Issue #3718
|
||||||
|
{reflect.ValueOf([]interface{}{"a"}), reflect.ValueOf([]string{"a", "b"}), "intersect", expect{true, false}},
|
||||||
|
{reflect.ValueOf([]string{"a"}), reflect.ValueOf([]interface{}{"a", "b"}), "intersect", expect{true, false}},
|
||||||
|
{reflect.ValueOf([]interface{}{1, 2}), reflect.ValueOf([]int{1}), "intersect", expect{true, false}},
|
||||||
|
{reflect.ValueOf([]int{1}), reflect.ValueOf([]interface{}{1, 2}), "intersect", expect{true, false}},
|
||||||
} {
|
} {
|
||||||
result, err := ns.checkCondition(test.value, test.match, test.op)
|
result, err := ns.checkCondition(test.value, test.match, test.op)
|
||||||
if test.expect.isError {
|
if test.expect.isError {
|
||||||
|
|
Loading…
Reference in a new issue