You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2018/07/13 15:44:22 UTC
[couchdb] 05/06: string:trim() compat for couch_util:trim()
This is an automated email from the ASF dual-hosted git repository.
jan pushed a commit to branch fix/2.1.2-sec
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 540c22e7e1fb768985ee4e52c3f40babd29e43a3
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Sun Jun 17 17:17:37 2018 +0200
string:trim() compat for couch_util:trim()
---
src/couch/src/couch_util.erl | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/couch/src/couch_util.erl b/src/couch/src/couch_util.erl
index 72ee73f..936b562 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))).