MiSawa / xq

Pure rust implementation of jq
MIT License
318 stars 18 forks source link

Fix split/1 with empty string, just as string division #90

Closed itchyny closed 2 years ago

itchyny commented 2 years ago

This PR fixes split/1 to work with empty string. This filter is semantically same as string division so I refactored not to duplicate code.

❯ jq -nc '"abc" | split("b", "")'
["a","c"]
["a","b","c"]

❯ jq -nc '"abc" / ("b", "")'
["a","c"]
["a","b","c"]

❯ xq -nc '"abc" | split("b", "")'
["a","c"]
["abc"]  # oops!

❯ xq -nc '"abc" / ("b", "")'
["a","c"]
["a","b","c"]  # ok!

❯ xq --version
xq 0.2.9-f33b40cf049d2ef44a4fa0f75f92efc9255fda62
MiSawa commented 2 years ago

Looks good, thank you!