mirror of
https://github.com/disposable-email-domains/disposable-email-domains.git
synced 2024-11-26 02:28:12 +08:00
Fix C# sample
This commit is contained in:
parent
b1c04c5bad
commit
41ae31c0eb
12
README.md
12
README.md
@ -103,10 +103,20 @@ private static readonly Lazy<HashSet<string>> _emailBlackList =
|
|||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private static bool IsBlacklisted(string domain)
|
||||||
|
{
|
||||||
|
var parts = domain.Split('.');
|
||||||
|
var len = parts.Length;
|
||||||
|
return
|
||||||
|
len == 1 && _emailBlackList.Value.Contains(domain)
|
||||||
|
|| _emailBlackList.Value.Contains($"{parts[len - 2]}.{parts[len - 1]}")
|
||||||
|
|| len > 2 && _emailBlackList.Value.Contains($"{parts[len - 3]}.{parts[len - 2]}.{parts[len - 1]}");
|
||||||
|
}
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
var addr = new MailAddress(email);
|
var addr = new MailAddress(email);
|
||||||
if (_emailBlackList.Value.Contains(addr.Host)))
|
if (IsBlacklisted(addr.Host)))
|
||||||
throw new ApplicationException("Email is blacklisted.");
|
throw new ApplicationException("Email is blacklisted.");
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user