summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2018-06-17 17:17:37 +0200
committerJan Lehnardt <jan@apache.org>2018-07-14 12:37:32 +0200
commit3c3546c7cc98831185e979a3aee63188a3a29fb2 (patch)
treedeb9017c511bb75b6f101be20214512c526f919b
parent5c93cb795d0960b8e5e88dd2c43ac77c87b56acb (diff)
downloadcouchdb-3c3546c7cc98831185e979a3aee63188a3a29fb2.tar.gz
string:trim() compat for couch_util:trim()
-rw-r--r--src/couch/src/couch_util.erl3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/couch/src/couch_util.erl b/src/couch/src/couch_util.erl
index 72ee73f95..936b562e1 100644
--- a/src/couch/src/couch_util.erl
+++ b/src/couch/src/couch_util.erl
@@ -338,6 +338,9 @@ is_whitespace(_Else) -> false.
% removes leading and trailing whitespace from a string
+trim(String) when is_binary(String) ->
+ % mirror string:trim() behaviour of returning a binary when a binary is passed in
+ ?l2b(trim(?b2l(String)));
trim(String) ->
String2 = lists:dropwhile(fun is_whitespace/1, String),
lists:reverse(lists:dropwhile(fun is_whitespace/1, lists:reverse(String2))).