imagekitio 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/imagekitio/sdk/version.rb +1 -1
- data/lib/imagekitio/url.rb +13 -37
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2a267b33b83b04a41e8a1623d436eef82320f7ef6e18febaf1ed7f8837c3851
|
4
|
+
data.tar.gz: b90444639b7197ad0fbade7c7092443877089f835e5b64108f25ec839125a21e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d447d460af09493e4dacc37796a15b48f4f6e15a5ac03dc3df01f1f2729e0411fee78c4f5ec0cf97a7c496bc73c6e2aaa1805c001fdf30e9114d495f7e8cb38
|
7
|
+
data.tar.gz: 53c26e7c92ebbdae23ab35faca95ba875a1b02a7fe63eb95bbd4e6a118adbd7c760498a9ec75bc4691bb4bcd6099551609d2ee1250d15a517d6952c85ed9630e
|
data/lib/imagekitio/url.rb
CHANGED
@@ -46,40 +46,31 @@ module ImageKitIo
|
|
46
46
|
end
|
47
47
|
|
48
48
|
result_url_hash = {'host': "", 'path': "", 'query': ""}
|
49
|
-
|
49
|
+
parsed_host = Addressable::URI.parse(url_endpoint)
|
50
|
+
existing_query = nil
|
50
51
|
if path != ""
|
51
52
|
parsed_url = Addressable::URI.parse(path)
|
52
|
-
existing_query=parsed_url.query
|
53
|
-
parsed_host = Addressable::URI.parse(url_endpoint)
|
54
|
-
result_url_hash[:scheme] = parsed_host.scheme
|
55
|
-
|
56
53
|
# making sure single '/' at end
|
57
54
|
result_url_hash[:host] = parsed_host.host.to_s.chomp("/") + parsed_host.path.chomp("/") + "/"
|
58
|
-
|
55
|
+
path_without_query = Addressable::URI.parse(path)
|
56
|
+
path_without_query.fragment = path_without_query.query = nil
|
57
|
+
result_url_hash[:path] = path_without_query.hostname.nil? ? trim_slash(path_without_query.to_s) : CGI.escape(trim_slash(path_without_query.to_s))
|
59
58
|
else
|
60
59
|
parsed_url = Addressable::URI.parse(src)
|
61
|
-
existing_query=parsed_url.query
|
62
|
-
host = parsed_url.host
|
63
60
|
result_url_hash[:userinfo] = parsed_url.userinfo if parsed_url.userinfo
|
64
|
-
result_url_hash[:host] = host
|
65
|
-
result_url_hash[:scheme] = parsed_url.scheme
|
61
|
+
result_url_hash[:host] = parsed_url.host
|
66
62
|
result_url_hash[:path] = parsed_url.path
|
67
63
|
src_param_used_for_url = true
|
68
64
|
end
|
65
|
+
|
66
|
+
existing_query = parsed_url.query
|
67
|
+
result_url_hash[:scheme] = parsed_host.scheme
|
69
68
|
query_params = {}
|
70
|
-
|
71
|
-
existing_query.split("&").each do |part|
|
72
|
-
parts=part.split("=")
|
73
|
-
if parts.length==2
|
74
|
-
query_params[parts[0]]=parts[1]
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
69
|
+
query_params = CGI.parse(existing_query).reject {|k, v| v.empty? }.transform_values(&:first) unless existing_query.nil?
|
78
70
|
options.fetch(:query_parameters, {}).each do |key, value|
|
79
|
-
query_params[key]=value
|
71
|
+
query_params[key] = value
|
80
72
|
end
|
81
73
|
transformation_str = transformation_to_str(options[:transformation]).chomp("/")
|
82
|
-
|
83
74
|
unless transformation_str.nil? || transformation_str.strip.empty?
|
84
75
|
if (transformation_position == constants.QUERY_TRANSFORMATION_POSITION) || src_param_used_for_url == true
|
85
76
|
result_url_hash[:query] = "#{constants.TRANSFORMATION_PARAMETER}=#{transformation_str}"
|
@@ -87,11 +78,10 @@ module ImageKitIo
|
|
87
78
|
else
|
88
79
|
result_url_hash[:path] = "#{constants.TRANSFORMATION_PARAMETER}:#{transformation_str}/#{result_url_hash[:path]}"
|
89
80
|
end
|
90
|
-
|
91
81
|
end
|
92
82
|
|
93
83
|
result_url_hash[:host] = result_url_hash[:host].to_s.reverse.chomp("/").reverse
|
94
|
-
result_url_hash[:path] = result_url_hash[:path].chomp("/")
|
84
|
+
result_url_hash[:path] = result_url_hash[:path].chomp("/") unless result_url_hash[:path].nil?
|
95
85
|
result_url_hash[:scheme] ||= "https"
|
96
86
|
|
97
87
|
query_param_arr = []
|
@@ -103,22 +93,9 @@ module ImageKitIo
|
|
103
93
|
query_param_arr.push(key.to_s + "=" + value.to_s)
|
104
94
|
end
|
105
95
|
end
|
106
|
-
|
107
96
|
query_param_str = query_param_arr.join("&")
|
108
97
|
result_url_hash[:query] = query_param_str
|
109
|
-
|
110
|
-
# Signature String and Timestamp
|
111
|
-
# We can do this only for URLs that are created using urlEndpoint and path parameter
|
112
|
-
# because we need to know the endpoint to be able to remove it from the URL to create a signature
|
113
|
-
# for the remaining. With the src parameter, we would not know the "pattern" in the URL
|
114
|
-
if options[:signed] && !(options[:src])
|
115
|
-
intermediate_url = result_url_hash.fetch(:scheme, "") + "://" + result_url_hash.fetch(:host, "") + result_url_hash.fetch(:path, "")
|
116
|
-
if result_url_hash[:query]!=nil && result_url_hash[:query]!=""
|
117
|
-
intermediate_url += result_url_hash.fetch(:query, "")
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
url=hash_to_url(result_url_hash)
|
98
|
+
url = hash_to_url(result_url_hash)
|
122
99
|
if options[:signed]
|
123
100
|
private_key = options[:private_key]
|
124
101
|
expire_seconds = options[:expire_seconds]
|
@@ -129,7 +106,6 @@ module ImageKitIo
|
|
129
106
|
if expire_timestamp && (expire_timestamp != constants.TIMESTAMP)
|
130
107
|
query_param_arr.push(constants.TIMESTAMP_PARAMETER + "=" + expire_timestamp.to_s)
|
131
108
|
end
|
132
|
-
|
133
109
|
query_param_str = query_param_arr.join("&")
|
134
110
|
result_url_hash[:query] = query_param_str
|
135
111
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imagekitio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ImageKit.io team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|