og_pilot_ruby 0.4.5 → 0.4.7

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: ee4898069ea1b40ff62e9db35ca4d5c726aaa27cf7b658c233c9f5f9bcc70bb2
4
- data.tar.gz: 4c38cee9d0e4753208e3b65c37c4b33a6b478fa1b34c9fd16cd98aca56836c56
3
+ metadata.gz: 7378c97e45ba7c02d8f8895b53614583443c0d393d56e0c8f4267941a65012d1
4
+ data.tar.gz: ec37c266916a73ce5610d7a9a74137bd1771dddf9f368db910c2d8f36880a1e9
5
5
  SHA512:
6
- metadata.gz: 2c1772c79ca7847a027611e42869888017b53e2e829a1262c519fb708d7e30e9fd4bce3bb0eb1ccc997c022a250b314ceadc88d3db5bcdb6c415c6aa23d5a177
7
- data.tar.gz: dced72f71149af6c1544bd11ff0803e10159d81e1f0039a58df025009e8527f7b4a1f4eca2bfe934d86e8d37f47a353bf9c6dfb1e32b4ba387d1ed8f4b01a66a
6
+ metadata.gz: b12fee2e4b63b2eb78942dfa301c7fdeaa44c205dacac2e505c05720370be0ca33da85ddcad5af19d64c9accca72098bc17942bb581ecc6492e14ca06d064fa1
7
+ data.tar.gz: ceb27ff2523496441e15247740db9dbb446fe59aebfe242f3f81b127e033bb66b57e0f774a9e7f3d549c000c8066d3ea1f509267ce3ed9bdf2d0d10a4eb96784
data/README.md CHANGED
@@ -683,20 +683,25 @@ OgPilotRuby.create_image(title: "Docs", path: "/docs.php")
683
683
  ### Strip query parameters
684
684
 
685
685
  When `strip_query_parameters` is enabled, the client drops the query string from
686
- every resolved path before it signs the payload. This keeps analytics grouped
687
- under the canonical path even when links include tracking or pagination
688
- parameters. It works alongside `strip_extensions`, so
689
- `/archive.tar.gz?ref=campaign` resolves to `"/archive"` when both are enabled.
686
+ every resolved path before it signs the payload, so `/docs?ref=main` and
687
+ `/docs?ref=next` are normalized to `"/docs"`. When both `strip_extensions` and
688
+ `strip_query_parameters` are enabled, the extension is removed first and the
689
+ query string is removed afterward, which means `/archive.tar.gz?ref=campaign`
690
+ becomes `"/archive"`.
690
691
 
691
692
  ```ruby
692
693
  OgPilotRuby.configure do |config|
693
694
  config.strip_query_parameters = true
695
+ config.strip_extensions = true
694
696
  end
695
697
 
696
698
  # These resolve to "/docs":
697
699
  OgPilotRuby.create_image(title: "Docs", path: "/docs")
698
700
  OgPilotRuby.create_image(title: "Docs", path: "/docs?ref=main")
699
- OgPilotRuby.create_image(title: "Docs", path: "https://example.com/docs?ref=campaign")
701
+
702
+ # Both of these resolve to "/archive":
703
+ OgPilotRuby.create_image(title: "Archive", path: "/archive.tar.gz")
704
+ OgPilotRuby.create_image(title: "Archive", path: "/archive.tar.gz?ref=campaign")
700
705
  ```
701
706
 
702
707
  ## Development
@@ -38,7 +38,8 @@ module OgPilotRuby
38
38
  result = if json
39
39
  JSON.parse(response.body)
40
40
  else
41
- response["Location"] || final_uri.to_s
41
+ url = response["Location"] || final_uri.to_s
42
+ status_placeholder?(url) ? nil : url
42
43
  end
43
44
 
44
45
  write_cached(cache_key, result, iat:) if config.cache_store && cache_key && result
@@ -102,6 +103,11 @@ module OgPilotRuby
102
103
  if response.is_a?(Net::HTTPRedirection)
103
104
  location = response["Location"]
104
105
  if location && !location.empty?
106
+ # Status placeholders (processing/failed) mean the image isn't ready yet.
107
+ # Return the redirect response as-is so the caller can detect this and
108
+ # avoid caching a temporary placeholder URL.
109
+ return [response, URI.join(uri.to_s, location)] if status_placeholder?(location)
110
+
105
111
  raise OgPilotRuby::RequestError, "OG Pilot request failed with too many redirects" if redirects_left <= 0
106
112
 
107
113
  redirect_uri = URI.join(uri.to_s, location)
@@ -131,6 +137,10 @@ module OgPilotRuby
131
137
  raise OgPilotRuby::RequestError, "OG Pilot request failed with unauthorized: #{e.message}"
132
138
  end
133
139
 
140
+ def status_placeholder?(url)
141
+ url.to_s.match?(%r{/status/(?:processing|failed)\.(?:jpg|png)\z})
142
+ end
143
+
134
144
  def build_http_request(method, uri)
135
145
  case method
136
146
  when :post
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OgPilotRuby
4
- VERSION = "0.4.5"
4
+ VERSION = "0.4.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: og_pilot_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sunergos IT LLC