Skip to content

Commit

Permalink
Minor performance optimization for cloudfront signers (#2974)
Browse files Browse the repository at this point in the history
  • Loading branch information
alextwoods authored Jan 10, 2024
1 parent 39fb594 commit b75eeed
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions gems/aws-sdk-cloudfront/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Unreleased Changes
------------------

* Issue - Minor performance optimization - replace gsub with delete.

1.86.0 (2023-11-28)
------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def signed_cookie(url, params = {})

cookie_parameters = {}
signature(content).each { |k, v|
cookie_parameters["CloudFront-#{k}"] = v.to_s.gsub("\n", '')
cookie_parameters["CloudFront-#{k}"] = v.to_s.delete("\n")
}
cookie_parameters
end
Expand Down
2 changes: 1 addition & 1 deletion gems/aws-sdk-cloudfront/lib/aws-sdk-cloudfront/signer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def scheme_and_uri(url)
if url_sections.length < 2
raise ArgumentError, "Invalid URL:#{url}"
end
scheme = url_sections[0].gsub('*', '')
scheme = url_sections[0].delete('*')
uri = "#{scheme}://#{url_sections[1]}"
[scheme, uri]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def signed_url(url, params = {})
)

start_flag = uri.include?('?') ? '&' : '?'
signature = signed_content.map{ |k, v| "#{k}=#{v}" }.join('&').gsub("\n", '')
signature = signed_content.map{ |k, v| "#{k}=#{v}" }.join('&').delete("\n")
uri = "#{uri}#{start_flag}#{signature}"

if scheme == 'rtmp'
Expand Down

0 comments on commit b75eeed

Please sign in to comment.