make disposable email detection case insensitive
parent
8006684863
commit
788eedc10f
|
@ -33,7 +33,7 @@ final class DisposableEmailDomain(
|
|||
}
|
||||
|
||||
private[security] def textToDomains(text: String): List[String] =
|
||||
text.lines.map(_.trim).filter(_.nonEmpty).toList
|
||||
text.lines.map(_.trim.toLowerCase).filter(_.nonEmpty).toList
|
||||
|
||||
private var failed = false
|
||||
|
||||
|
@ -54,11 +54,12 @@ final class DisposableEmailDomain(
|
|||
(s: String) => matcher(s).matches
|
||||
}
|
||||
|
||||
def isMainstream = DisposableEmailDomain.mainstreamDomains.contains _
|
||||
def isMainstream(domain: String) =
|
||||
DisposableEmailDomain.mainstreamDomains contains domain.toLowerCase
|
||||
|
||||
def apply(domain: String) =
|
||||
if (isMainstream(domain)) false
|
||||
else matchers exists { _(domain) }
|
||||
else matchers exists { _(domain.toLowerCase) }
|
||||
}
|
||||
|
||||
object DisposableEmailDomain {
|
||||
|
|
|
@ -14,6 +14,8 @@ class DisposableEmailDomainTest extends Specification {
|
|||
d("hotmail.com") must beFalse
|
||||
d("live.com") must beFalse
|
||||
d("docmail.cz") must beTrue
|
||||
d("DoCmAiL.cz") must beTrue
|
||||
d("chacuo.net") must beTrue
|
||||
}
|
||||
"suffix" in {
|
||||
d("foo.some.randomgoodemail.org") must beFalse
|
||||
|
|
|
@ -4,7 +4,7 @@ case object Fixtures {
|
|||
|
||||
def text = """
|
||||
leeching.net
|
||||
chacuo.net
|
||||
ChaCuo.net
|
||||
027168.com
|
||||
0-mail.com
|
||||
mail1a.de
|
||||
|
|
Loading…
Reference in New Issue