Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Env#domain_match? now returns true if no domains specified

  • Loading branch information...
commit c7d32fec863a1521eef2c766e34930e9a3669914 1 parent ec0d190
@winton authored
Showing with 10 additions and 2 deletions.
  1. +4 −2 lib/a_b/model/env.rb
  2. +6 −0 spec/a_b/model/env_spec.rb
View
6 lib/a_b/model/env.rb
@@ -4,15 +4,17 @@ class Env < ActiveRecord::Base
belongs_to :user
def domain_match?(referer)
+ d = (domains || '').split(',')
match =
begin
- domains.split(',').detect do |domain|
+ d.empty? ||
+ d.detect do |domain|
r = referer.match(/:\/\/([^:\/]+)/)[1]
r[(-1*domain.length)..-1] == domain
end
rescue Exception => e
nil
end
- !match.nil?
+ !match.nil? && match != false
end
end
View
6 spec/a_b/model/env_spec.rb
@@ -31,5 +31,11 @@
@env.domain_match?('http://blah.com:9393/blah').should == false
@env.domain_match?('http://blah.com').should == false
end
+
+ it "should return true if no domains specified" do
+ @env.domains = nil
+ @env.domain_match?('http://blah.com:9393/blah').should == true
+ @env.domain_match?('http://blah.com').should == true
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.