Skip to content

Instantly share code, notes, and snippets.

@kylev
Created June 28, 2011 03:03
Show Gist options
  • Save kylev/1050398 to your computer and use it in GitHub Desktop.
Save kylev/1050398 to your computer and use it in GitHub Desktop.
Attempt to prevent errors from subdomain-fu on 2.3.8 when people request/probe using an IP-based URL
diff --git a/lib/core_extensions/action_controller_request.rb b/lib/core_extensions/action_controller_request.rb
index fcd578c..08bdd4a 100644
--- a/lib/core_extensions/action_controller_request.rb
+++ b/lib/core_extensions/action_controller_request.rb
@@ -7,4 +7,11 @@ class ActionController::Request
end
end
+
+ BASE_CHANGE_DOMAIN = ENV['BASE_URL'].split(':')[0]
+ # We only have one domain, so attempt to fall back to it when someone fails to provide a Host: header or is otherwise lame.
+ def domain_with_default
+ domain_without_default || BASE_CHANGE_DOMAIN
+ end
+ alias_method_chain :domain, :default
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment