cloudinary 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cloudinary/utils.rb +8 -4
- data/lib/cloudinary/version.rb +1 -1
- metadata +2 -2
data/lib/cloudinary/utils.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Copyright Cloudinary
|
2
2
|
require 'digest/sha1'
|
3
|
+
require 'zlib'
|
3
4
|
|
4
5
|
class Cloudinary::Utils
|
5
6
|
SHARED_CDN = "d3jpl91pxevbkh.cloudfront.net"
|
@@ -51,7 +52,7 @@ class Cloudinary::Utils
|
|
51
52
|
private_cdn = options.delete(:private_cdn) || Cloudinary.config.private_cdn
|
52
53
|
secure_distribution = options.delete(:secure_distribution) || Cloudinary.config.secure_distribution
|
53
54
|
force_remote = options.delete(:force_remote)
|
54
|
-
|
55
|
+
|
55
56
|
if !force_remote
|
56
57
|
return source if (type.nil? || type == :asset) && source.match(%r(^https?:/)i)
|
57
58
|
if source.start_with?("/")
|
@@ -73,6 +74,9 @@ class Cloudinary::Utils
|
|
73
74
|
end
|
74
75
|
end
|
75
76
|
type ||= :upload
|
77
|
+
|
78
|
+
source = "#{source}.#{format}" if format && type != :fetch
|
79
|
+
source = smart_escape(source) if [:fetch, :asset].include?(type)
|
76
80
|
|
77
81
|
if cloud_name.start_with?("/")
|
78
82
|
prefix = "/res" + cloud_name
|
@@ -88,13 +92,13 @@ class Cloudinary::Utils
|
|
88
92
|
if secure
|
89
93
|
prefix = "https://#{secure_distribution}"
|
90
94
|
else
|
91
|
-
|
95
|
+
cdn_subdomain = options.include?(:cdn_subdomain) ? options[:cdn_subdomain] : Cloudinary.config.cdn_subdomain
|
96
|
+
subdomain = cdn_subdomain ? "a#{(Zlib::crc32(source) % 5) + 1}." : ""
|
97
|
+
prefix = "http://#{subdomain}#{private_cdn ? "#{cloud_name}-" : ""}res.cloudinary.com"
|
92
98
|
end
|
93
99
|
prefix += "/#{cloud_name}" if !private_cdn
|
94
100
|
end
|
95
101
|
|
96
|
-
source = "#{source}.#{format}" if format && type != :fetch
|
97
|
-
source = smart_escape(source) if [:fetch, :asset].include?(type)
|
98
102
|
source = prefix + "/" + [resource_type,
|
99
103
|
type, transformation, version ? "v#{version}" : nil,
|
100
104
|
source].reject(&:blank?).join("/").gsub(%r(([^:])//), '\1/')
|
data/lib/cloudinary/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cloudinary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nadav Soferman
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2012-04-
|
15
|
+
date: 2012-04-15 00:00:00 +03:00
|
16
16
|
default_executable:
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|