couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vatam...@apache.org
Subject [couchdb] branch 63012-scheduler updated: [fixup] add strip_url_creds tests
Date Mon, 10 Apr 2017 17:59:21 GMT
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch 63012-scheduler
in repository https://gitbox.apache.org/repos/asf/couchdb.git

The following commit(s) were added to refs/heads/63012-scheduler by this push:
       new  359a888   [fixup] add strip_url_creds tests
359a888 is described below

commit 359a888c0ede3b6c10205873cfd8e6b5ca9f6453
Author: Nick Vatamaniuc <vatamane@apache.org>
AuthorDate: Mon Apr 10 13:59:16 2017 -0400

    [fixup] add strip_url_creds tests
---
 src/couch_replicator/src/couch_replicator.erl      |  7 ++++++-
 src/couch_replicator/src/couch_replicator_docs.erl | 15 ++++++++++-----
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/couch_replicator/src/couch_replicator.erl b/src/couch_replicator/src/couch_replicator.erl
index 0b66331..883c832 100644
--- a/src/couch_replicator/src/couch_replicator.erl
+++ b/src/couch_replicator/src/couch_replicator.erl
@@ -419,7 +419,12 @@ t_strip_http_basic_creds() ->
         Url1 = <<"http://adm:pass@host/db">>,
         ?assertEqual(<<"http://adm:*****@host/db/">>, strip_url_creds(Url1)),
         Url2 = <<"https://adm:pass@host/db">>,
-        ?assertEqual(<<"https://adm:*****@host/db/">>, strip_url_creds(Url2))
+        ?assertEqual(<<"https://adm:*****@host/db/">>, strip_url_creds(Url2)),
+        Url3 = <<"http://adm:pass@host:80/db">>,
+        ?assertEqual(<<"http://adm:*****@host:80/db/">>, strip_url_creds(Url3)),
+        Url4 = <<"http://adm:pass@host/db?a=b&c=d">>,
+        ?assertEqual(<<"http://adm:*****@host/db?a=b&c=d">>,
+            strip_url_creds(Url4))
     end).
 
 
diff --git a/src/couch_replicator/src/couch_replicator_docs.erl b/src/couch_replicator/src/couch_replicator_docs.erl
index 6859d5b..c8c677a 100644
--- a/src/couch_replicator/src/couch_replicator_docs.erl
+++ b/src/couch_replicator/src/couch_replicator_docs.erl
@@ -452,11 +452,16 @@ parse_rep_db(undefined, _Proxy, _Options) ->
 maybe_add_trailing_slash(Url) when is_binary(Url) ->
     maybe_add_trailing_slash(?b2l(Url));
 maybe_add_trailing_slash(Url) ->
-    case lists:last(Url) of
-    $/ ->
-        Url;
-    _ ->
-        Url ++ "/"
+    case lists:member($?, Url) of
+        true ->
+            Url;  % skip if there are query params
+        false ->
+            case lists:last(Url) of
+                $/ ->
+                    Url;
+                _ ->
+                    Url ++ "/"
+            end
     end.
 
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <commits@couchdb.apache.org>'].

Mime
View raw message