properly insert into empty strings
This commit is contained in:
parent
92809b1d03
commit
c392c33ad8
@ -176,6 +176,10 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
|
||||
QuoteKind::None => QuoteKind::None,
|
||||
};
|
||||
|
||||
if s1.is_empty() {
|
||||
return Ok(Value::Ident(substr, quotes));
|
||||
}
|
||||
|
||||
let len = s1.len();
|
||||
|
||||
// Insert substring at char position, rather than byte position
|
||||
|
@ -141,6 +141,11 @@ test!(
|
||||
);
|
||||
test!(
|
||||
str_insert_empty_string,
|
||||
"a {\n color: str-insert(\"\", \"abcd\", 4);\n}\n",
|
||||
"a {\n color: \"abcd\";\n}\n"
|
||||
);
|
||||
test!(
|
||||
str_insert_empty_substring,
|
||||
"a {\n color: str-insert(abcd, \"\", 4);\n}\n",
|
||||
"a {\n color: abcd;\n}\n"
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user