Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for options in info_url #221

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/imgproxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def configure
config
end

# Genrates imgproxy URL
# Generates imgproxy URL
#
# Imgproxy.url_for(
# "http://images.example.com/images/image.jpg",
Expand Down Expand Up @@ -114,7 +114,7 @@ def url_for(image, options = {})
Imgproxy::Builder.new(options).url_for(image)
end

# Genrates imgproxy info URL. Supported only by imgproxy pro
# Generates imgproxy info URL. Supported only by imgproxy pro
#
# Imgproxy.info_url_for("http://images.example.com/images/image.jpg")
#
Expand Down
6 changes: 3 additions & 3 deletions lib/imgproxy/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def initialize(options = {})
@format = @options.delete(:format)
end

# Genrates imgproxy URL
# Generates imgproxy URL
#
# @return [String] imgproxy URL
# @param [String,URI, Object] image Source image URL or object applicable for
Expand All @@ -45,14 +45,14 @@ def url_for(image)
File.join(endpoint.to_s, signature, path)
end

# Genrates imgproxy info URL
# Generates imgproxy info URL
#
# @return [String] imgproxy info URL
# @param [String,URI, Object] image Source image URL or object applicable for
# the configured URL adapters
# @see Imgproxy.info_url_for
def info_url_for(image)
path = url(image)
path = [*processing_options, url(image)].join("/")
signature = sign_path(path)

File.join(endpoint.to_s, "info", signature, path)
Expand Down
5 changes: 5 additions & 0 deletions spec/imgproxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,11 @@
)
end

it "adds options to the info URL" do
options = { palette: 2 }
expect(described_class.info_url_for(src_url, options)).to include("palette:2")
end

context "when base64_encode_urls is true" do
before { described_class.config.base64_encode_urls = true }

Expand Down