<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,11 +1,11 @@
 module ActionController
   module UrlWriter
     def url_for_with_subdomains(options)
-      unless SubdomainFu.needs_rewrite?(options[:subdomain], options[:host] || default_url_options[:host])
-        options.delete(:subdomain)
-      else
+      if SubdomainFu.needs_rewrite?(options[:subdomain], options[:host] || default_url_options[:host]) || options[:only_path] == false
         options[:only_path] = false 
         options[:host] = SubdomainFu.rewrite_host_for_subdomains(options.delete(:subdomain), options[:host] || default_url_options[:host])
+      else
+        options.delete(:subdomain)
       end
       url_for_without_subdomains(options)
     end
@@ -16,11 +16,11 @@ module ActionController
     private
     
     def rewrite_url_with_subdomains(options)
-      unless SubdomainFu.needs_rewrite?(options[:subdomain], options[:host] || @request.host_with_port)
-        options.delete(:subdomain)
-      else
+      if SubdomainFu.needs_rewrite?(options[:subdomain], options[:host] || @request.host_with_port) || options[:only_path] == false
         options[:only_path] = false
         options[:host] = SubdomainFu.rewrite_host_for_subdomains(options.delete(:subdomain), options[:host] || @request.host_with_port)
+      else
+        options.delete(:subdomain)
       end
       rewrite_url_without_subdomains(options)
     end</diff>
      <filename>lib/subdomain_fu/url_rewriter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -112,6 +112,11 @@ describe &quot;SubdomainFu URL Writing&quot; do
       needs_subdomain_url(:subdomain =&gt; false).should == &quot;http://www.testapp.com/needs_subdomain&quot;
     end
 
+    it &quot;should switch to the preferred mirror automatically&quot; do
+      default_url_options[:host] = &quot;testapp.com&quot;
+      needs_subdomain_url.should == &quot;http://www.testapp.com/needs_subdomain&quot;
+    end
+
     it &quot;should force a switch to no subdomain on a mirror if preferred_mirror is false&quot; do
       SubdomainFu.preferred_mirror = false
       default_url_options[:host] = &quot;www.testapp.com&quot;</diff>
      <filename>spec/url_rewriter_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>dab049be969bc848e313bab45ff8ed029f6befdf</id>
    </parent>
  </parents>
  <author>
    <name>Eric Lindvall</name>
    <email>eric@5stops.com</email>
  </author>
  <url>http://github.com/mbleigh/subdomain-fu/commit/60d86ad414634f4822835cdc0851a6939c90c586</url>
  <id>60d86ad414634f4822835cdc0851a6939c90c586</id>
  <committed-date>2009-05-26T06:33:37-07:00</committed-date>
  <authored-date>2009-05-25T23:19:40-07:00</authored-date>
  <message>Rewrite URLs to use the preferred mirror if a full URL is being generated.

Signed-off-by: Michael Bleigh &lt;michael@intridea.com&gt;</message>
  <tree>b237e751c50e8bf3d7fa18184ba708200d5788a3</tree>
  <committer>
    <name>Michael Bleigh</name>
    <email>michael@intridea.com</email>
  </committer>
</commit>
