spike out THE BLACKLIST
This commit is contained in:
parent
d6fff16968
commit
f03894d2f2
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.DS_Store
|
||||
Gemfile.lock
|
||||
*.gem
|
||||
|
||||
1
.ruby-version
Normal file
1
.ruby-version
Normal file
@ -0,0 +1 @@
|
||||
2.0.0
|
||||
11
lib/swot.rb
11
lib/swot.rb
@ -123,6 +123,13 @@ module Swot
|
||||
'vic.edu.au' => 1,
|
||||
}
|
||||
|
||||
# These are domains that snuck into the edu registry,
|
||||
# but don't pass the education sniff test
|
||||
# Note: domain must be a direct match
|
||||
BLACKLIST = [
|
||||
'si.edu',
|
||||
]
|
||||
|
||||
class << self
|
||||
|
||||
# Figure out if an email or domain belongs to academic institution.
|
||||
@ -135,7 +142,9 @@ module Swot
|
||||
domain = get_domain(text)
|
||||
return false if domain.nil?
|
||||
|
||||
if ACADEMIC_TLDS[domain.tld]
|
||||
if BLACKLIST.include? domain.name
|
||||
false
|
||||
elsif ACADEMIC_TLDS[domain.tld]
|
||||
true
|
||||
elsif match_academic_domain?(domain)
|
||||
true
|
||||
|
||||
@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
||||
]
|
||||
s.files = [
|
||||
".document",
|
||||
".rbenv-version",
|
||||
".ruby-version",
|
||||
"CONTRIBUTING.md",
|
||||
"Gemfile",
|
||||
"LICENSE.txt",
|
||||
@ -7725,4 +7725,3 @@ Gem::Specification.new do |s|
|
||||
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -58,4 +58,10 @@ class TestEmail < Test::Unit::TestCase
|
||||
assert_equal Swot::academic?('stanford.edu'), true
|
||||
assert_equal Swot::school_name('lreilly@cs.strath.ac.uk'), "University of Strathclyde"
|
||||
end
|
||||
|
||||
should "fail blacklisted domains" do
|
||||
["si.edu", " si.edu ", "imposter@si.edu"].each do |domain|
|
||||
assert_equal false, Swot::is_academic?(domain), "#{domain} should be denied"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user