<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -54,14 +54,15 @@ module SubdomainFu
   
   # Rewrites the subdomain of the host unless they are equivalent (i.e. mirrors of each other)
   def self.rewrite_host_for_subdomains(subdomain, host)
-    unless needs_rewrite?(subdomain, host)
-      if has_subdomain?(subdomain) || preferred_mirror?(subdomain_from(host))
+    if needs_rewrite?(subdomain, host)
+      change_subdomain_of_host(subdomain || SubdomainFu.preferred_mirror, host)
+    else
+      if has_subdomain?(subdomain) || preferred_mirror?(subdomain_from(host)) ||
+          (subdomain.nil? &amp;&amp; has_subdomain?(subdomain_from(host)))
         host
       else
         change_subdomain_of_host(SubdomainFu.preferred_mirror, host)
       end
-    else
-      change_subdomain_of_host(subdomain || SubdomainFu.preferred_mirror, host)
     end
   end
   
@@ -101,7 +102,6 @@ module SubdomainFu
     end
     
     protected
-    
     def current_subdomain
       SubdomainFu.current_subdomain(request)
     end</diff>
      <filename>lib/subdomain-fu.rb</filename>
    </modified>
    <modified>
      <diff>@@ -98,11 +98,15 @@ describe &quot;SubdomainFu&quot; do
     it &quot;should remove the subdomain if passed false when it's not a mirror&quot; do
       SubdomainFu.rewrite_host_for_subdomains(false,&quot;cool.localhost&quot;).should == &quot;localhost&quot;
     end
-    
+
     it &quot;should not remove the subdomain if passed false when it is a mirror&quot; do
       SubdomainFu.rewrite_host_for_subdomains(false,&quot;www.localhost&quot;).should == &quot;www.localhost&quot;
     end
 
+    it &quot;should not remove the subdomain if passed nil when it's not a mirror&quot; do
+      SubdomainFu.rewrite_host_for_subdomains(nil,&quot;cool.localhost&quot;).should == &quot;cool.localhost&quot;
+    end
+
     describe &quot;when preferred_mirror is false&quot; do
       before do
         SubdomainFu.preferred_mirror = false
@@ -111,6 +115,10 @@ describe &quot;SubdomainFu&quot; do
       it &quot;should remove the subdomain if passed false when it is a mirror&quot; do
         SubdomainFu.rewrite_host_for_subdomains(false,&quot;www.localhost&quot;).should == &quot;localhost&quot;
       end
+
+      it &quot;should not remove the subdomain if passed nil when it's not a mirror&quot; do
+        SubdomainFu.rewrite_host_for_subdomains(nil,&quot;cool.localhost&quot;).should == &quot;cool.localhost&quot;
+      end
     end
   end
   
@@ -176,6 +184,7 @@ describe &quot;SubdomainFu&quot; do
       end
 
       it { SubdomainFu.needs_rewrite?(false,&quot;www.localhost&quot;).should be_true }
+      it { SubdomainFu.needs_rewrite?(nil,&quot;awesome.localhost&quot;).should be_false }
     end
   end
 end
\ No newline at end of file</diff>
      <filename>spec/subdomain_fu_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -117,6 +117,11 @@ describe &quot;SubdomainFu URL Writing&quot; do
       needs_subdomain_url.should == &quot;http://www.testapp.com/needs_subdomain&quot;
     end
 
+    it &quot;should work when passed in a paramable object and no subdomain to a _url&quot; do
+      default_url_options[:host] = &quot;awesome.testapp.com&quot;
+      foo_url(Paramed.new(&quot;something&quot;)).should == &quot;http://awesome.testapp.com/foos/something&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>60d86ad414634f4822835cdc0851a6939c90c586</id>
    </parent>
  </parents>
  <author>
    <name>Eric Lindvall</name>
    <email>eric@5stops.com</email>
  </author>
  <url>http://github.com/mbleigh/subdomain-fu/commit/a141cdabb13cae9ed0cb416c111ae0a6125eef5b</url>
  <id>a141cdabb13cae9ed0cb416c111ae0a6125eef5b</id>
  <committed-date>2009-05-26T06:34:13-07:00</committed-date>
  <authored-date>2009-05-26T00:01:42-07:00</authored-date>
  <message>Add another test case for param-based URL generation.

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