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
17
18
19
# 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
  # repeat any query params after the fragment to deal with Angular eating any pre fragment query params, used
  # in the reset password redirect url
  res += "?#{query}" if uri.fragment

  res
end

.whitelisted?(url) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
# File 'lib/devise_token_auth/url.rb', line 21

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