og_pilot_ruby 0.4.4 → 0.4.6
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cfefae49c597192416e12b3ce37cbeb6c9a96978cd0117544cab4ed3d334d754
|
|
4
|
+
data.tar.gz: 1ad8da7a1af0b52c0a039fce941d5e35c0718317586fbe694b537886c6e7e14d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3c43d41211ef1bbe5685565ce341adea1c9e56b8007e322c37a7561ee5b068ba944176826a7455546ec6580b53b3a8b3f640064ad30dada66a25df1035230f1a
|
|
7
|
+
data.tar.gz: 8967f05bb0129386f0b8397f401918ccecc54127a6f939066615a960fa98433e3863579bfc59b926373631b0d0513624c8fff68a3715c8fff0192d464a8b5f90
|
data/README.md
CHANGED
|
@@ -566,6 +566,7 @@ The gem handles `iss` (domain) and `sub` (API key prefix) automatically.
|
|
|
566
566
|
| `open_timeout` | `5` | Connection timeout in seconds |
|
|
567
567
|
| `read_timeout` | `10` | Read timeout in seconds |
|
|
568
568
|
| `strip_extensions` | `true` | When `true`, file extensions are stripped from resolved paths (see [Strip extensions](#strip-extensions)) |
|
|
569
|
+
| `strip_query_parameters` | `false` | When `true`, query strings are removed from resolved paths before signing (see [Strip query parameters](#strip-query-parameters)) |
|
|
569
570
|
| `cache_store` | `nil` | Optional cache backend with `read`/`write` (for example `Rails.cache`) |
|
|
570
571
|
| `cache_ttl` | `86400` | Cache TTL in seconds when `cache_store` is enabled |
|
|
571
572
|
|
|
@@ -679,6 +680,30 @@ OgPilotRuby.create_image(title: "Docs", path: "/docs.php")
|
|
|
679
680
|
# Dotfiles are unchanged: /.hidden stays /.hidden
|
|
680
681
|
```
|
|
681
682
|
|
|
683
|
+
### Strip query parameters
|
|
684
|
+
|
|
685
|
+
When `strip_query_parameters` is enabled, the client drops the query string from
|
|
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"`.
|
|
691
|
+
|
|
692
|
+
```ruby
|
|
693
|
+
OgPilotRuby.configure do |config|
|
|
694
|
+
config.strip_query_parameters = true
|
|
695
|
+
config.strip_extensions = true
|
|
696
|
+
end
|
|
697
|
+
|
|
698
|
+
# These resolve to "/docs":
|
|
699
|
+
OgPilotRuby.create_image(title: "Docs", path: "/docs")
|
|
700
|
+
OgPilotRuby.create_image(title: "Docs", path: "/docs?ref=main")
|
|
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")
|
|
705
|
+
```
|
|
706
|
+
|
|
682
707
|
## Development
|
|
683
708
|
|
|
684
709
|
Run tests with:
|
data/lib/og_pilot_ruby/client.rb
CHANGED
|
@@ -253,6 +253,7 @@ module OgPilotRuby
|
|
|
253
253
|
cleaned = extract_request_uri(cleaned)
|
|
254
254
|
cleaned = "/#{cleaned}" unless cleaned.start_with?("/")
|
|
255
255
|
cleaned = strip_extension(cleaned) if config.strip_extensions
|
|
256
|
+
cleaned = remove_query_parameters(cleaned) if config.strip_query_parameters
|
|
256
257
|
cleaned
|
|
257
258
|
end
|
|
258
259
|
|
|
@@ -278,6 +279,11 @@ module OgPilotRuby
|
|
|
278
279
|
query ? "#{stripped}?#{query}" : stripped
|
|
279
280
|
end
|
|
280
281
|
|
|
282
|
+
def remove_query_parameters(path)
|
|
283
|
+
stripped = path.split("?", 2).first
|
|
284
|
+
stripped.empty? ? "/" : stripped
|
|
285
|
+
end
|
|
286
|
+
|
|
281
287
|
def extract_request_uri(value)
|
|
282
288
|
return value unless value.start_with?("http://", "https://")
|
|
283
289
|
|
|
@@ -5,7 +5,7 @@ module OgPilotRuby
|
|
|
5
5
|
DEFAULT_BASE_URL = "https://ogpilot.com"
|
|
6
6
|
private_constant :DEFAULT_BASE_URL
|
|
7
7
|
|
|
8
|
-
attr_accessor :api_key, :domain, :base_url, :open_timeout, :read_timeout, :strip_extensions, :cache_store, :cache_ttl
|
|
8
|
+
attr_accessor :api_key, :domain, :base_url, :open_timeout, :read_timeout, :strip_extensions, :strip_query_parameters, :cache_store, :cache_ttl
|
|
9
9
|
|
|
10
10
|
def initialize
|
|
11
11
|
@api_key = ENV.fetch("OG_PILOT_API_KEY", nil)
|
|
@@ -14,6 +14,7 @@ module OgPilotRuby
|
|
|
14
14
|
@open_timeout = 5
|
|
15
15
|
@read_timeout = 10
|
|
16
16
|
@strip_extensions = true
|
|
17
|
+
@strip_query_parameters = false
|
|
17
18
|
@cache_store = nil
|
|
18
19
|
@cache_ttl = 86400
|
|
19
20
|
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.
|
|
4
|
+
version: 0.4.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sunergos IT LLC
|
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
97
97
|
- !ruby/object:Gem::Version
|
|
98
98
|
version: '0'
|
|
99
99
|
requirements: []
|
|
100
|
-
rubygems_version: 4.0.
|
|
100
|
+
rubygems_version: 4.0.6
|
|
101
101
|
specification_version: 4
|
|
102
102
|
summary: Ruby client for the OG Pilot Open Graph image generator.
|
|
103
103
|
test_files: []
|