Replace SimpleIDN usage with Addressable (#11238)
This commit is contained in:
parent
9154437fe0
commit
16c3ccb955
5 changed files with 3 additions and 6 deletions
1
Gemfile
1
Gemfile
|
|
@ -92,7 +92,6 @@ gem "sassc-rails", "~> 2.1.2" # Integrate SassC-Ruby into Rails
|
|||
gem "sidekiq", "~> 6.1.2" # Sidekiq is used to process background jobs with the help of Redis
|
||||
gem "sidekiq-cron", "~> 1.1" # Allows execution of scheduled cron jobs as specific times
|
||||
gem "sidekiq-unique-jobs", "~> 6.0.25" # Ensures that Sidekiq jobs are unique when enqueued
|
||||
gem "simpleidn", "~> 0.1" # Convert IDN domains to Punycode
|
||||
gem "sitemap_generator", "~> 6.1" # SitemapGenerator is a framework-agnostic XML Sitemap generator
|
||||
gem "slack-notifier", "~> 2.3" # A slim ruby wrapper for posting to slack webhooks
|
||||
gem "sprockets", "~> 4.0" # Sprockets is a Rack-based asset packaging system
|
||||
|
|
|
|||
|
|
@ -733,8 +733,6 @@ GEM
|
|||
json (>= 1.8, < 3)
|
||||
simplecov-html (~> 0.10.0)
|
||||
simplecov-html (0.10.2)
|
||||
simpleidn (0.1.1)
|
||||
unf (~> 0.1.4)
|
||||
sitemap_generator (6.1.2)
|
||||
builder (~> 3.0)
|
||||
slack-notifier (2.3.2)
|
||||
|
|
@ -964,7 +962,6 @@ DEPENDENCIES
|
|||
sidekiq-cron (~> 1.1)
|
||||
sidekiq-unique-jobs (~> 6.0.25)
|
||||
simplecov (= 0.17.1)
|
||||
simpleidn (~> 0.1)
|
||||
sitemap_generator (~> 6.1)
|
||||
slack-notifier (~> 2.3)
|
||||
spring (~> 2.1)
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@ module ApplicationHelper
|
|||
|
||||
return unless (image_url = url.presence || fallback_image)
|
||||
|
||||
Images::Optimizer.call(SimpleIDN.to_ascii(image_url), width: width, quality: quality, fetch_format: fetch_format)
|
||||
normalized_url = Addressable::URI.parse(image_url).normalize.to_s
|
||||
Images::Optimizer.call(normalized_url, width: width, quality: quality, fetch_format: fetch_format)
|
||||
end
|
||||
|
||||
def optimized_image_tag(image_url, optimizer_options: {}, image_options: {})
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ RSpec.describe ApplicationHelper, type: :helper do
|
|||
end
|
||||
|
||||
it "returns an ASCII domain for Unicode input" do
|
||||
expect(helper.optimized_image_url("https://www.火.dev/image.png")).to include("https://www.xn--vnx.dev")
|
||||
expect(helper.optimized_image_url("https://www.火.dev/IMAGE.png")).to include("https://www.xn--vnx.dev/IMAGE.png")
|
||||
end
|
||||
|
||||
it "keeps an ASCII domain as ASCII" do
|
||||
|
|
|
|||
BIN
vendor/cache/simpleidn-0.1.1.gem
vendored
BIN
vendor/cache/simpleidn-0.1.1.gem
vendored
Binary file not shown.
Loading…
Add table
Reference in a new issue