remove the hard coded escaping from split row and split column (#4731)

This commit is contained in:
Darren Schroeder 2022-03-04 15:09:35 -06:00 committed by GitHub
parent 02dfb57ed1
commit 5b3cc73ac6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View File

@ -114,12 +114,10 @@ fn split_column_helper(
head: Span, head: Span,
) -> Vec<Value> { ) -> Vec<Value> {
if let Ok(s) = v.as_string() { if let Ok(s) = v.as_string() {
let splitter = separator.item.replace("\\n", "\n");
let split_result: Vec<_> = if collapse_empty { let split_result: Vec<_> = if collapse_empty {
s.split(&splitter).filter(|s| !s.is_empty()).collect() s.split(&separator.item).filter(|s| !s.is_empty()).collect()
} else { } else {
s.split(&splitter).collect() s.split(&separator.item).collect()
}; };
let positional: Vec<_> = rest.iter().map(|f| f.item.clone()).collect(); let positional: Vec<_> = rest.iter().map(|f| f.item.clone()).collect();

View File

@ -86,8 +86,7 @@ fn split_row_helper(v: &Value, separator: &Spanned<String>, name: Span) -> Vec<V
match v.span() { match v.span() {
Ok(v_span) => { Ok(v_span) => {
if let Ok(s) = v.as_string() { if let Ok(s) = v.as_string() {
let splitter = separator.item.replace("\\n", "\n"); s.split(&separator.item)
s.split(&splitter)
.filter_map(|s| { .filter_map(|s| {
if s.trim() != "" { if s.trim() != "" {
Some(Value::string(s, v_span)) Some(Value::string(s, v_span))