couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [couchdb] 01/03: Replace header match with regexp
Date Fri, 15 Dec 2017 18:32:18 GMT
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch elixir-suite-davisp
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit c5edfa6fbd121510af066c9f800f206b8072586f
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
AuthorDate: Fri Dec 15 12:30:22 2017 -0600

    Replace header match with regexp
    
    This just makes the Content-Type check slightly more robust.
---
 test/elixir/lib/couch.ex | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/test/elixir/lib/couch.ex b/test/elixir/lib/couch.ex
index 5119011..8f0aca9 100644
--- a/test/elixir/lib/couch.ex
+++ b/test/elixir/lib/couch.ex
@@ -28,11 +28,10 @@ defmodule Couch do
   end
 
   def process_response_body(headers, body) do
-    case headers[:'content-type'] do
-      "application/json" ->
-        body |> IO.iodata_to_binary |> :jiffy.decode([:return_maps])
-      _ ->
-        process_response_body(body)
+    if String.match?(headers[:"Content-Type"], ~r/application\/json/) do
+      body |> IO.iodata_to_binary |> :jiffy.decode([:return_maps])
+    else
+      process_response_body(body)
     end
   end
 

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

Mime
View raw message