Repository: MiSawa/xq (rust)

Issue:
Division by empty string yields array with empty strings at start and end
```sh
❯ jq -c '. / ""' <<< '"abcde"'
["a","b","c","d","e"]

❯ xq -c '. / ""' <<< '"abcde"'
["","a","b","c","d","e",""]

❯ xq --version                
xq 0.1.9-b5d6c8d747459413aadf8298237f1628edbbd9e7
```


Pull request:
Fix division by empty string
Fixes #47 

Patch:
diff --git a/src/intrinsic/binary.rs b/src/intrinsic/binary.rs
index b70dd2d..879c107 100644
--- a/src/intrinsic/binary.rs
+++ b/src/intrinsic/binary.rs
@@ -126,6 +126,11 @@ fn divide(lhs: Value, rhs: Value) -> Result<Value, QueryExecutionError> {
             }
             Value::number(lhs / rhs)
         }
+        (String(lhs), String(rhs)) if rhs.is_empty() => lhs
+            .chars()
+            .map(|c| c.to_string().into())
+            .collect::<crate::Array>()
+            .into(),
         (String(lhs), String(rhs)) => lhs
             .split(&*rhs)
             .into_iter()


Test patch:
diff --git a/tests/hand_written/mod.rs b/tests/hand_written/mod.rs
index 67773e1..8f1335d 100644
--- a/tests/hand_written/mod.rs
+++ b/tests/hand_written/mod.rs
@@ -203,3 +203,19 @@ test!(
     [1,[2,3]]
     "#
 );
+
+test!(
+    split_empty_string,
+    r#"
+    . / ""
+    "#,
+    r#"
+    "abcde"
+    ""
+    "#,
+    r#"
+    ["a","b","c","d","e"]
+    []
+    "#
+);
+