You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/06 13:55:22 UTC

[45/48] couch commit: updated refs/heads/windsor-merge-300 to 2c2f53e

Use the new b64url NIF

This is uses the new b64url NIF for performaing Base64 URL encoding and
decoding.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/aa35d4f9
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/aa35d4f9
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/aa35d4f9

Branch: refs/heads/windsor-merge-300
Commit: aa35d4f90205474fc0c5bc817227223f1ba53f6d
Parents: dfa15da
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Nov 21 13:47:32 2013 -0600
Committer: Robert Newson <rn...@apache.org>
Committed: Wed Aug 6 12:49:04 2014 +0100

----------------------------------------------------------------------
 src/couch.app.src  | 2 +-
 src/couch_util.erl | 9 ++-------
 2 files changed, 3 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/aa35d4f9/src/couch.app.src
----------------------------------------------------------------------
diff --git a/src/couch.app.src b/src/couch.app.src
index 8007278..30f3b2a 100644
--- a/src/couch.app.src
+++ b/src/couch.app.src
@@ -29,5 +29,5 @@
     ]},
     {mod, {couch_app, []}},
     {applications, [kernel, stdlib, crypto, sasl, inets, oauth, ibrowse,
-        mochiweb, ssl, couch_log, couch_event]}
+        mochiweb, ssl, couch_log, couch_event, b64url]}
 ]}.

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/aa35d4f9/src/couch_util.erl
----------------------------------------------------------------------
diff --git a/src/couch_util.erl b/src/couch_util.erl
index 20dfdaf..6f84ac7 100644
--- a/src/couch_util.erl
+++ b/src/couch_util.erl
@@ -307,15 +307,10 @@ should_flush(MemThreshHold) ->
     true -> false end.
 
 encodeBase64Url(Url) ->
-    Url1 = re:replace(base64:encode(Url), ["=+", $$], ""),
-    Url2 = re:replace(Url1, "/", "_", [global]),
-    re:replace(Url2, "\\+", "-", [global, {return, binary}]).
+    b64url:encode(Url).
 
 decodeBase64Url(Url64) ->
-    Url1 = re:replace(Url64, "-", "+", [global]),
-    Url2 = re:replace(Url1, "_", "/", [global]),
-    Padding = lists:duplicate((4 - iolist_size(Url2) rem 4) rem 4, $=),
-    base64:decode(iolist_to_binary([Url2, Padding])).
+    b64url:decode(Url64).
 
 dict_find(Key, Dict, DefaultValue) ->
     case dict:find(Key, Dict) of