mixpal 0.4.0 → 0.4.2

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: 70923329c62f76ee4d6b0796547cdd2e367038940c30d8f5ccb10b044f506d36
4
- data.tar.gz: 492801097fa1ac2fb85f4600273b2db3fc6e0e8383c9b17112e0302100fc9020
3
+ metadata.gz: 9a28fcdf5ca00ceb1a7abed59a6f90d8dcd7d7216c204ad76a87497a656dd4a7
4
+ data.tar.gz: 7c510ab982f230147a03bab655c8a7fb8da373310b817ead61fc6ea06d77f358
5
5
  SHA512:
6
- metadata.gz: b8dbd5bd3051e8edf9ab7b130c0cd6a5af876d52c8fb6992e82c4ae3b22b58eeb726591bffc67368c9cc3c40e60faa2a1f5d5090a3392fe5fc96f374dde1af6e
7
- data.tar.gz: e32c5e8e487ea31dc875df217e26f962c634978cd07b1d036b97a10f3e7eaa0fb8d446b0e8c00d89c4a5eacce591012400d01e3b541bd98238114a4ea1785aaf
6
+ metadata.gz: fd6c7aa7a15bdec83398610de7431f0d185f9650522a614204b7bb63bcaa7470147faa7ed301f3cbd9c5967164ab2d92ebaa90a5b8e4445947e2073864261f72
7
+ data.tar.gz: ec9c80f83fe4b8e20735c61c359306d68dbf0a60b7d9ba74515dcb60be7d7f5f237ab14a1d1e7951e75280158ea8c78f42f886c497decc5416159b04713533fa
@@ -32,7 +32,7 @@ module Mixpal
32
32
  private
33
33
 
34
34
  def store_mixpanel_if_redirecting
35
- mixpanel.store!(session) if status == 302
35
+ mixpanel.store!(session) if (300..399).cover?(status)
36
36
  end
37
37
  end
38
38
  end
data/lib/mixpal/util.rb CHANGED
@@ -5,12 +5,22 @@ module Mixpal
5
5
  hash.reject! { |_, v| v.nil? }
6
6
 
7
7
  contents = hash.map do |k, v|
8
- js_value = v.is_a?(String) || v.is_a?(Time) ? "\"#{v}\"" : v
9
- "\"#{k}\": #{js_value}"
8
+ "\"#{k}\": #{escape_js_object_value(v)}"
10
9
  end.join(',').html_safe
11
10
 
12
11
  "{#{contents}}"
13
12
  end
13
+
14
+ def escape_js_object_value(value)
15
+ case value
16
+ when String
17
+ value.dump
18
+ when Time
19
+ "\"#{value}\""
20
+ else
21
+ value
22
+ end
23
+ end
14
24
  end
15
25
  end
16
26
  end
@@ -1,3 +1,3 @@
1
1
  module Mixpal
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.2'
3
3
  end
@@ -24,5 +24,10 @@ describe Mixpal::Util do
24
24
  expect(subject.hash_to_js_object_string(age: 21, gender: nil))
25
25
  .to eq '{"age": 21}'
26
26
  end
27
+
28
+ it 'escapes double quotes in values' do
29
+ expect(subject.hash_to_js_object_string(key: 'value "with" quotes'))
30
+ .to eq '{"key": "value \"with\" quotes"}'
31
+ end
27
32
  end
28
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixpal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - patbenatar
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-09-20 00:00:00.000000000 Z
12
+ date: 2023-11-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler