1
0

domain_control_helper.rb 487 B

12345678910111213141516171819202122232425
  1. # frozen_string_literal: true
  2. module DomainControlHelper
  3. def domain_not_allowed?(uri_or_domain)
  4. return if uri_or_domain.blank?
  5. domain = begin
  6. if uri_or_domain.include?('://')
  7. Addressable::URI.parse(uri_or_domain).host
  8. else
  9. uri_or_domain
  10. end
  11. end
  12. if whitelist_mode?
  13. !DomainAllow.allowed?(domain)
  14. else
  15. DomainBlock.blocked?(domain)
  16. end
  17. end
  18. def whitelist_mode?
  19. Rails.configuration.x.whitelist_mode
  20. end
  21. end