lib/ckeditor5/rails/cdn/url_generator.rb in ckeditor5-1.10.0 vs lib/ckeditor5/rails/cdn/url_generator.rb in ckeditor5-1.11.0
- old
+ new
@@ -18,24 +18,26 @@
}
}.freeze
CDN_COMMERCIAL_GENERATORS = {
cloud: lambda { |bundle, version, path|
- domain = bundle == 'ckbox' ? 'ckbox.io' : 'ckeditor.com'
+ "https://cdn.ckeditor.com/#{bundle}/#{version}/#{path}"
+ },
- "https://cdn.#{domain}/#{bundle}/#{version}/#{path}"
+ ckbox: lambda { |bundle, version, path|
+ "https://cdn.ckbox.io/#{bundle}/#{version}/#{path}"
}
}.freeze
included do
attr_reader :cdn
end
def create_cdn_url(bundle, version, path)
- generator = CDN_THIRD_PARTY_GENERATORS[cdn] || CDN_COMMERCIAL_GENERATORS[cdn] || cdn
+ executor = CDN_THIRD_PARTY_GENERATORS[cdn] || CDN_COMMERCIAL_GENERATORS[cdn] || cdn
- raise ArgumentError, "Unknown provider: #{cdn}" unless generator
+ raise ArgumentError, "Unknown provider: #{cdn}" if executor.blank? || !executor.respond_to?(:call)
- generator.call(bundle, version, path)
+ executor.call(bundle, version, path)
end
end
end