url_tokenizer 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 383116a0335fab26f54f76cfdd73f05363ab8f50
4
- data.tar.gz: 0672bcc8b9ada416f6d3ff903965365961428845
3
+ metadata.gz: 1b457a2c1764fdf030bb170f3c9772eff9f01238
4
+ data.tar.gz: 843287412ab80ef4a06e147060d91055caaeb5b1
5
5
  SHA512:
6
- metadata.gz: f7b018000703293b316d08edd2bc4c57dea06054753cec2501581bea113116cd4cc7efea241a40abbf34edb0727a7d3ba72959b85e5c97512c96805314edce9d
7
- data.tar.gz: a63a20a9315b0ec9a5659bc96d1623e12bffbe75f2b1e040c8b9fec9fd1e897b641878d9cae05ca01d9ebdec92476e2ef5e4d3ca934d69f3ea61544d20e4b6f6
6
+ metadata.gz: b82d7e5d12b2221d486d27885612b77dc9218b060204a3ef21c1832d7e07604b5d36e488b2d2998ed8382acc4b753ef9486a93671f87ae7143e404c810e2961f
7
+ data.tar.gz: c4ee7dc583c929b493acf07d0a739f22a572a002f1bd5eb08bd0874493996d625f3c16b0fbc52f1c733d83dc9cd404783120b661f194566363d380a57366f9be
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.4.0
@@ -1,4 +1,5 @@
1
1
  require_relative 'fastly'
2
+ require 'rack'
2
3
 
3
4
  module UrlTokenizer
4
5
  class FastlyQueryString < Fastly
@@ -9,13 +10,31 @@ module UrlTokenizer
9
10
  return if path.empty? || path == '/'
10
11
 
11
12
  expiration = expiration_date(options[:expires_in])
12
- dir = File.dirname(path)
13
13
 
14
- token = digest [dir, expiration].compact.join
14
+ token = digest [string_to_tokenize(uri), expiration].compact.join
15
15
  token = [expiration, token].compact.join '_'
16
16
 
17
- uri.query = build_query token: token
17
+ params = parse_query_string(uri).merge(token: token)
18
+
19
+ uri.query = build_query params
18
20
  uri.to_s
19
21
  end
22
+
23
+ def string_to_tokenize(uri)
24
+ query = parse_query_string(uri)
25
+ return query['chname'] if query.include?('chname')
26
+
27
+ File.basename File.dirname(uri.path)
28
+ end
29
+
30
+ private
31
+
32
+ def parse_query_string(uri)
33
+ return {} if uri.query.nil?
34
+
35
+ Rack::Utils.parse_query(uri.query).tap do |params|
36
+ params.delete('token')
37
+ end
38
+ end
20
39
  end
21
40
  end
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.0"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rack"
24
25
  spec.add_development_dependency "rspec", "~> 3.0"
25
26
  spec.add_development_dependency "dotenv"
26
27
  spec.add_development_dependency "codeclimate-test-reporter"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: url_tokenizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Paramonov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-10 00:00:00.000000000 Z
11
+ date: 2017-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facets
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -154,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
168
  version: '0'
155
169
  requirements: []
156
170
  rubyforge_project:
157
- rubygems_version: 2.6.10
171
+ rubygems_version: 2.4.5
158
172
  signing_key:
159
173
  specification_version: 4
160
174
  summary: Tokenize url by variety of providers.