diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index 2367231359088..c5adfcd83a8dc 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -23,7 +23,7 @@ def extract_subdomain(host, tld_length = @@tld_length) end def url_for(options = {}) - unless options[:host].present? || options[:only_path].present? + if options[:host].blank? && options[:only_path].blank? raise ArgumentError, 'Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true' end @@ -54,7 +54,7 @@ def url_for(options = {}) private def named_host?(host) - !(host.nil? || IP_HOST_REGEXP.match(host)) + host && IP_HOST_REGEXP !~ host end def rewrite_authentication(options)