Skip to content

Commit 9b360eb

Browse files
authored
Adds expires to supported options (#181)
* Adds expires to supported options * Use existing test
1 parent 884c674 commit 9b360eb

5 files changed

Lines changed: 9 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ builder.url_for("http://images.example.com/images/image2.jpg")
236236
- [filename](https://docs.imgproxy.net/#/generating_the_url_advanced?id=filename)
237237
- [format](https://docs.imgproxy.net/#/generating_the_url_advanced?id=format)
238238
- [return_attachment](https://docs.imgproxy.net/#/generating_the_url_advanced?id=return-attachment)
239+
- [expires](https://docs.imgproxy.net/#/generating_the_url?id=expires)
239240

240241
_See [imgproxy URL format guide](https://docs.imgproxy.net/#/generating_the_url_advanced?id=processing-options) for more info._
241242

lib/imgproxy.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def configure
101101
# @option options [String] :filename
102102
# @option options [String] :format
103103
# @option options [Boolean] :return_attachment
104+
# @option options [Integer] :expires
104105
# @option options [Boolean] :use_short_options
105106
# @option options [Boolean] :base64_encode_urls
106107
# @option options [Boolean] :escape_plain_url

lib/imgproxy/options.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class Options < Hash
6565
filename: Imgproxy::OptionsCasters::String,
6666
format: Imgproxy::OptionsCasters::String,
6767
return_attachment: Imgproxy::OptionsCasters::Bool,
68+
expires: Imgproxy::OptionsCasters::Integer,
6869
}.freeze
6970

7071
META = %i[size resize adjust].freeze

lib/imgproxy/options_aliases.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ module Imgproxy
4040
auto_rotate: :ar,
4141
filename: :fn,
4242
return_attachment: :att,
43+
expires: :exp,
4344
}.freeze
4445
end

spec/imgproxy_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
filename: "the_image.jpg",
122122
format: :webp,
123123
return_attachment: true,
124+
expires: Time.at(4810374983),
124125
}
125126
end
126127

@@ -166,7 +167,8 @@
166167
"scp:0/"\
167168
"ar:1/"\
168169
"fn:the_image.jpg/"\
169-
"att:1"
170+
"att:1/"\
171+
"exp:4810374983"
170172
end
171173

172174
let(:casted_options_full) do
@@ -210,7 +212,8 @@
210212
"strip_color_profile:0/"\
211213
"auto_rotate:1/"\
212214
"filename:the_image.jpg/"\
213-
"return_attachment:1"
215+
"return_attachment:1/"\
216+
"expires:4810374983"
214217
end
215218
# rubocop: enable Layout/LineEndStringConcatenationIndentation
216219

0 commit comments

Comments
 (0)