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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/url_tokenizer/fastly.rb +10 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 383116a0335fab26f54f76cfdd73f05363ab8f50
|
4
|
+
data.tar.gz: 0672bcc8b9ada416f6d3ff903965365961428845
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7b018000703293b316d08edd2bc4c57dea06054753cec2501581bea113116cd4cc7efea241a40abbf34edb0727a7d3ba72959b85e5c97512c96805314edce9d
|
7
|
+
data.tar.gz: a63a20a9315b0ec9a5659bc96d1623e12bffbe75f2b1e040c8b9fec9fd1e897b641878d9cae05ca01d9ebdec92476e2ef5e4d3ca934d69f3ea61544d20e4b6f6
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.1
|
data/lib/url_tokenizer/fastly.rb
CHANGED
@@ -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 [
|
17
|
+
token = digest [dir, expiration].compact.join
|
16
18
|
token = [expiration, token].compact.join '_'
|
17
19
|
|
18
|
-
uri.
|
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
|