Module: Browserctl::Policy

Defined in:
lib/browserctl/policy.rb

Class Method Summary collapse

Class Method Details

.allowed_navigation?(url) ⇒ Boolean

Returns true if the URL is permitted by the domain policy. When BROWSERCTL_ALLOWED_DOMAINS is unset, all URLs are allowed.

Parameters:

  • url (String)

    the URL to check

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
# File 'lib/browserctl/policy.rb', line 11

def self.allowed_navigation?(url)
  domains = allowed_domains
  return true if domains.empty?

  host_matches?(URI.parse(url).host, domains)
rescue URI::InvalidURIError
  false
end