url_tokenizer 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/url_tokenizer/fastly.rb +10 -3
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc1c6093170ce607d703963d8d6d76227c35a634
4
- data.tar.gz: 39c39fc1ae56dd9fe286e3db59bd588cf90365c7
3
+ metadata.gz: 383116a0335fab26f54f76cfdd73f05363ab8f50
4
+ data.tar.gz: 0672bcc8b9ada416f6d3ff903965365961428845
5
5
  SHA512:
6
- metadata.gz: 3c4157d89ab23ece8988f0c3dfcb94b24a60c98d41863fadd532c211ffc9984e04ebdea0f95671ecccad82e6bbdc557b21d0baa1f9ede2a28b65a91c293ff9e5
7
- data.tar.gz: c356ff40f9e68a677e64bffd4481bb4eefeaaef67cf8d322bcfe0611ba31bd068b98ee586030ca801bdb0177f9ab73be9abd50b783bdb31c619915e46e9c1e34
6
+ metadata.gz: f7b018000703293b316d08edd2bc4c57dea06054753cec2501581bea113116cd4cc7efea241a40abbf34edb0727a7d3ba72959b85e5c97512c96805314edce9d
7
+ data.tar.gz: a63a20a9315b0ec9a5659bc96d1623e12bffbe75f2b1e040c8b9fec9fd1e897b641878d9cae05ca01d9ebdec92476e2ef5e4d3ca934d69f3ea61544d20e4b6f6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.3.1
@@ -7,21 +7,28 @@ module UrlTokenizer
7
7
  def call(input_url, **options)
8
8
  options = global_options.merge options
9
9
  uri = URI.parse input_url
10
- path = uri.path
10
+ path = remove_old_token(uri.path)
11
+
11
12
  return if path.empty? || path == '/'
12
13
 
13
14
  expiration = expiration_date(options[:expires_in])
15
+ dir = File.dirname(path)
14
16
 
15
- token = digest [path, expiration].compact.join
17
+ token = digest [dir, expiration].compact.join
16
18
  token = [expiration, token].compact.join '_'
17
19
 
18
- uri.query = build_query token: token
20
+ uri.path = ['/', token, path].join
19
21
  uri.to_s
20
22
  end
21
23
 
22
24
  private
25
+
23
26
  def digest(string_to_sign)
24
27
  OpenSSL::HMAC.hexdigest('sha1', key, string_to_sign)
25
28
  end
29
+
30
+ def remove_old_token(path)
31
+ path.sub(/\d{10,}_\w{40}\/?/, '')
32
+ end
26
33
  end
27
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: url_tokenizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Paramonov