hubrise_initializer 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 382ed88d72aceb55e7cc9e65fc93be9415919c88759637252ba356e4c1d00721
4
- data.tar.gz: fed70b073a0a56e416c38aa292fe94e53363f91fe50e4cab3f08c463a090f53e
3
+ metadata.gz: 66f2a6620893b4928f509dceaf4693f00d44e8f7372670d0bb29cb6aae7f88dc
4
+ data.tar.gz: 0b740151154568d2b42a49f0e508a333b164079a75fbca4513e62c1b4e78d5ce
5
5
  SHA512:
6
- metadata.gz: 63e0994eb3f19d066d133228a566972fe91edba3f6bad916e6d1172b40d8b72c7cdcceb9491cbb4361d81cbfea30c8f9dbe3b0e814846219a3a671f3e0a68a38
7
- data.tar.gz: 3413d1ae4814d3a1ed6671e2688f5013e79706ab27e29e88c1d202b5d9485e5bd9cb5e5bdccc1c78df4b6def8342d03f597f29eee4845ad210e4d7358eb0c341
6
+ metadata.gz: 38773d3d4ee8cb07554786a4db4cf84625a8d5106b34295cc11914401e8110347217b564d60acb5a817e66e6a3e04fd1fc62f31a54c49dcfd53ba139f24cca48
7
+ data.tar.gz: 5e37b26c88b4ae570aa938ff59deedbdffc3e7df0862dacab9ec9ee8cda884f900d6b3d0e40d6847f4ca2b5f4535f7a527a0fdf11a61395614d43f4cdc7fc531
@@ -17,9 +17,9 @@ class HubriseInitializer
17
17
  if ENV['RAILS_LOGRAGE_QUERY'] == 'true'
18
18
  {
19
19
  request_headers: process_request_headers(request).to_s,
20
- request_body: truncate_body(switch_to_utf8(request.raw_post, "Binary (#{request.raw_post.size} bytes)")),
20
+ request_body: truncate_body(switch_to_utf8(request.raw_post)),
21
21
  response_headers: response.headers.to_h.to_s,
22
- response_body: truncate_body(response.body),
22
+ response_body: truncate_body(switch_to_utf8(response.body))
23
23
  }
24
24
  else
25
25
  {}
@@ -31,12 +31,17 @@ class HubriseInitializer
31
31
 
32
32
  TRUNCATED_BODY_MAX_LENGTH = 1000
33
33
 
34
- # Switch string encoding to utf-8. Return fallback if not a valid utf-8 sequence.
35
- def switch_to_utf8(s, fallback)
34
+ # Attempt to switch string encoding to utf-8. Return fallback if not a valid utf-8 sequence.
35
+ def switch_to_utf8(s)
36
+ return if !s
37
+
38
+ return s if s.encoding == Encoding::UTF_8
39
+
36
40
  s_utf_8 = s.dup.force_encoding(Encoding::UTF_8)
37
- s_utf_8.valid_encoding? ?
38
- s_utf_8 :
39
- fallback
41
+ return s_utf_8 if s_utf_8.valid_encoding?
42
+
43
+ # Fallback for binary data
44
+ return "Binary (#{s.size} bytes)"
40
45
  end
41
46
 
42
47
  def truncate_body(s)
@@ -1,3 +1,3 @@
1
1
  class HubriseInitializer
2
- VERSION = '0.2.5'.freeze
2
+ VERSION = '0.2.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubrise_initializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antoine Monnier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-21 00:00:00.000000000 Z
11
+ date: 2019-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lograge