Module: DeviseTokenAuth::Url

Defined in:
lib/devise_token_auth/url.rb

Defined Under Namespace

Classes: Wildcat

Class Method Summary collapse

Class Method Details

.generate(url, params = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/devise_token_auth/url.rb', line 5

def self.generate(url, params = {})
  uri = URI(url)

  res = "#{uri.scheme}://#{uri.host}"
  res += ":#{uri.port}" if (uri.port && uri.port != 80 && uri.port != 443)
  res += uri.path.to_s if uri.path
  query = [uri.query, params.to_query].reject(&:blank?).join('&')
  res += "?#{query}"
  res += "##{uri.fragment}" if uri.fragment

  res
end

.whitelisted?(url) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
# File 'lib/devise_token_auth/url.rb', line 18

def self.whitelisted?(url)
  url.nil? || \
    !!DeviseTokenAuth.redirect_whitelist.find do |pattern|
      !!Wildcat.new(pattern).match(url)
    end
end