Class: UrlTokenizer::CDN77

Inherits:
Provider show all
Defined in:
lib/url_tokenizer/cdn77.rb

Instance Method Summary collapse

Methods inherited from Provider

#initialize

Constructor Details

This class inherits a constructor from UrlTokenizer::Provider

Instance Method Details

#call(input_url, **options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/url_tokenizer/cdn77.rb', line 8

def call(input_url, **options)
  options = global_options.merge options
  uri = URI.parse input_url
  path = uri.path
  return if path.empty? || path == '/'

  expiration = expiration_date(options[:expires_in])
  token = digest [expiration, path, key].compact.join
  token = [token, expiration].compact.join ','

  uri.query = build_query secure: token
  uri.to_s
end