Fix rtrimstr("") always output "" (#3415)
Example
---
**Before this fix**:
```sh
$ jq -n '"foo"|rtrimstr("")'
""
```
**After this fix**:
```sh
$ jq -n '"foo"|rtrimstr("")'
"foo"
```
This commit is contained in:
1 parent
c8017bf079
commit
169457328d
2 files changed
+13
-1
No files matched your search
+1
-1
@@ -75,7 +75,7 @@ def todateiso8601: strftime("%Y-%m-%dT%H:%M:%SZ");
|
|||||||
def fromdate: fromdateiso8601;
|
def fromdate: fromdateiso8601;
|
||||||
def todate: todateiso8601;
|
def todate: todateiso8601;
|
||||||
def ltrimstr($left): if startswith($left) then .[$left | length:] end;
|
def ltrimstr($left): if startswith($left) then .[$left | length:] end;
|
||||||
def rtrimstr($right): if endswith($right) then .[:$right | -length] end;
|
def rtrimstr($right): if endswith($right) then .[:length - ($right | length)] end;
|
||||||
def trimstr($val): ltrimstr($val) | rtrimstr($val);
|
def trimstr($val): ltrimstr($val) | rtrimstr($val);
|
||||||
def match(re; mode): _match_impl(re; mode; false)|.[];
|
def match(re; mode): _match_impl(re; mode; false)|.[];
|
||||||
def match($val): ($val|type) as $vt | if $vt == "string" then match($val; null)
|
def match($val): ($val|type) as $vt | if $vt == "string" then match($val; null)
|
||||||
|
|||||||
@@ -1512,6 +1512,18 @@ split("")
|
|||||||
["fo", "foo", "barfoo", "foobarfoo", "foob"]
|
["fo", "foo", "barfoo", "foobarfoo", "foob"]
|
||||||
["fo","","bar","bar","b"]
|
["fo","","bar","bar","b"]
|
||||||
|
|
||||||
|
[.[]|ltrimstr("")]
|
||||||
|
["a", "xx", ""]
|
||||||
|
["a", "xx", ""]
|
||||||
|
|
||||||
|
[.[]|rtrimstr("")]
|
||||||
|
["a", "xx", ""]
|
||||||
|
["a", "xx", ""]
|
||||||
|
|
||||||
|
[.[]|trimstr("")]
|
||||||
|
["a", "xx", ""]
|
||||||
|
["a", "xx", ""]
|
||||||
|
|
||||||
[(index(","), rindex(",")), indices(",")]
|
[(index(","), rindex(",")), indices(",")]
|
||||||
"a,bc,def,ghij,klmno"
|
"a,bc,def,ghij,klmno"
|
||||||
[1,13,[1,4,8,13]]
|
[1,13,[1,4,8,13]]
|
||||||
|
|||||||
Reference in new issue
Block a user