str-slice start/end equality does not preclude output

This commit is contained in:
ConnorSkees 2020-03-23 14:16:27 -04:00
parent 893c758e13
commit 991b87f335
2 changed files with 6 additions and 1 deletions

View File

@ -111,7 +111,7 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
end = str_len;
}
if start >= end || start > str_len {
if start > end || start > str_len {
Ok(Value::Ident(String::new(), quotes.normalize()))
} else {
let s = string[start - 1..end].to_string();

View File

@ -93,6 +93,11 @@ test!(
"a {\n color: str-slice($string: \"foo\", $start-at: 99999999999999999999, $end-at: -99999999999999999999);\n}\n",
"a {\n color: \"\";\n}\n"
);
test!(
str_slice_start_end_equal,
"a {\n color: str-slice(\"cde\", 1, 1);\n}\n",
"a {\n color: \"c\";\n}\n"
);
test!(
str_len_dbl_quotes,
"a {\n color: str-length(\"cde\");\n}\n",