compare filepath and string (#2897)

This commit is contained in:
Darren Schroeder 2021-01-09 14:09:49 -06:00 committed by GitHub
parent 363dc51ba0
commit 9de2144fc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,6 +63,14 @@ fn string_contains(
UntaggedValue::Primitive(Primitive::String(l)),
UntaggedValue::Primitive(Primitive::String(r)),
) => Ok(l.contains(r)),
(
UntaggedValue::Primitive(Primitive::FilePath(l)),
UntaggedValue::Primitive(Primitive::String(r)),
) => Ok(l.as_path().display().to_string().contains(r)),
(
UntaggedValue::Primitive(Primitive::String(l)),
UntaggedValue::Primitive(Primitive::FilePath(r)),
) => Ok(l.contains(&r.as_path().display().to_string())),
_ => Err((left.type_name(), right.type_name())),
}
}