capi_param_builder_ruby 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8acc5a9893deeb3ac84eb9973c23fe5bf498d86ac00c3afcee5320ffd18a50e9
4
- data.tar.gz: 5dd4b0017743d2a06b2c8a6c4c8b04d77052a2e642d2d9912895002e220bb62a
3
+ metadata.gz: 4a33297523bdd07b142d4a946e4b3134675aec7d95d3479dad27647e566e36e4
4
+ data.tar.gz: e62d98b35b46fd27adb878d736f8640c8cb589d437f94a7a19ab9d986eb2d38c
5
5
  SHA512:
6
- metadata.gz: 2ae3b35cc6ddf7b8cce4a0a1a12ebbe57befeb3cfd3e0f546c78468ec0684253a5ee68c2fbc92eda827fbb1dbb3e0cd829c2327ce9afbd5f8c1f9b15eef8253c
7
- data.tar.gz: fd12cf81cda06e7b2a72e38e46d68371fff2e0debdc5238fe8bd16ee04b9ca9396af40d0b2f3393370db29565907c76623d6caea369eec9eb29e5eb237ff9798
6
+ metadata.gz: 0c0a171eb5f541ca08f7a08c23f7505bdc5a00818668126698b440ea2268670f17bedefeadf10f2b6b89a9c504111a55b1050a2988180a12165c28e5e3cd5498
7
+ data.tar.gz: a44149e6a88bddb67c82239b9f680668fc54f73e4ed6fcc16c6748b541110c1086e9f639cfca24aca7ac701ec11568e45cb2a5e8dae92f5fd3c0c1fd5dc071ea
@@ -29,10 +29,17 @@ class ParamBuilder
29
29
  APPENDIX_LENGTH_V1 = 2
30
30
  APPENDIX_LENGTH_V2 = 8
31
31
 
32
+ # Appendix type constants
33
+ APPENDIX_NO_CHANGE = 0x00
34
+ APPENDIX_GENERAL_NEW = 0x01
35
+ APPENDIX_NET_NEW = 0x02
36
+ APPENDIX_MODIFIED_NEW = 0x03
37
+
32
38
  def initialize(input = nil)
33
39
  @fbc_params_configs = [FbcParamConfigs.new("fbclid", "", "clickID")]
34
- @appendix_new = get_appendix(true)
35
- @appendix_normal = get_appendix(false)
40
+ @appendix_net_new = get_appendix(APPENDIX_NET_NEW)
41
+ @appendix_modified_new = get_appendix(APPENDIX_MODIFIED_NEW)
42
+ @appendix_no_change = get_appendix(APPENDIX_NO_CHANGE)
36
43
 
37
44
  if input.nil?
38
45
  return
@@ -48,7 +55,7 @@ class ParamBuilder
48
55
  end
49
56
  end
50
57
 
51
- private def get_appendix(is_new)
58
+ private def get_appendix(appendix_type)
52
59
  begin
53
60
  version = ReleaseConfig::VERSION
54
61
  version_parts = version.split(".")
@@ -56,13 +63,19 @@ class ParamBuilder
56
63
  minor = version_parts[1].to_i
57
64
  patch = version_parts[2].to_i
58
65
 
59
- is_new_byte = is_new ? 0x01 : 0x00
66
+ # Validate appendix type
67
+ valid_types = [APPENDIX_NET_NEW, APPENDIX_GENERAL_NEW, APPENDIX_MODIFIED_NEW]
68
+ if valid_types.include?(appendix_type)
69
+ type_byte = appendix_type
70
+ else
71
+ type_byte = APPENDIX_NO_CHANGE
72
+ end
60
73
 
61
74
  # Create byte array
62
75
  bytes_array = [
63
76
  DEFAULT_FORMAT, # 0x01 = 1
64
77
  LANGUAGE_TOKEN_INDEX, # 0x05 = 5
65
- is_new_byte, # 0x01 when is_new=true, 0x00 when is_new=false
78
+ type_byte, # appendix type
66
79
  major, # Major version number
67
80
  minor, # Minor version number
68
81
  patch # Patch version number
@@ -104,7 +117,7 @@ class ParamBuilder
104
117
  end
105
118
  # Append language token if not present
106
119
  if parts.size == MIN_PAYLOAD_SPLIT_LENGTH
107
- updated_cookie_value = cookie_value + "." + @appendix_normal
120
+ updated_cookie_value = cookie_value + "." + @appendix_no_change
108
121
  @cookie_to_set_dict[cookie_name] = CookieSettings.new(
109
122
  cookie_name, updated_cookie_value, @etld_plus_one, DEFAULT_1PC_AGE)
110
123
  return updated_cookie_value
@@ -282,17 +295,26 @@ class ParamBuilder
282
295
  return nil
283
296
  end
284
297
 
298
+ cookie_update = false
299
+ is_net_new = false
285
300
  if existing_fbc.nil?
286
301
  cookie_update = true
302
+ is_net_new = true
287
303
  else
288
304
  parts = existing_fbc.split(/\./)
289
- cookie_update = new_fbc_payload != parts[3]
305
+ if parts.size < MIN_PAYLOAD_SPLIT_LENGTH
306
+ cookie_update = true
307
+ is_net_new = true
308
+ else
309
+ cookie_update = new_fbc_payload != parts[3]
310
+ end
290
311
  end
291
312
  if cookie_update == false
292
313
  return nil
293
314
  end
294
315
 
295
316
  current_ms = (Time.now.to_f * 1000).to_i.to_s
317
+ appendix = is_net_new ? @appendix_net_new : @appendix_modified_new
296
318
  new_fbc = "fb." +
297
319
  @sub_domain_index.to_s +
298
320
  "." +
@@ -300,7 +322,7 @@ class ParamBuilder
300
322
  "." +
301
323
  new_fbc_payload +
302
324
  "." +
303
- @appendix_new
325
+ appendix
304
326
  updated_cookie_setting = CookieSettings.new(
305
327
  FBC_NAME, new_fbc, @etld_plus_one, DEFAULT_1PC_AGE)
306
328
  return updated_cookie_setting
@@ -319,7 +341,7 @@ class ParamBuilder
319
341
  "." +
320
342
  new_fbp_payload +
321
343
  "." +
322
- @appendix_new
344
+ @appendix_net_new
323
345
  updated_cookie_setting = CookieSettings.new(
324
346
  FBP_NAME, new_fbp, @etld_plus_one, DEFAULT_1PC_AGE)
325
347
  return updated_cookie_setting
@@ -1,3 +1,8 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+
4
+ # This source code is licensed under the license found in the
5
+ # LICENSE file in the root directory of this source tree.
1
6
  module ReleaseConfig
2
- VERSION = "1.1.0"
7
+ VERSION = "1.1.1"
3
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capi_param_builder_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Facebook
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-13 00:00:00.000000000 Z
11
+ date: 2026-01-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: