From 1a7de49fe188fb9a2ec2da1601731f0b77ae67f8 Mon Sep 17 00:00:00 2001 From: Benjamin Piouffle Date: Wed, 29 Aug 2018 15:57:25 +0200 Subject: [PATCH] Add is_burner_domain function and update providers --- CHANGELOG.md | 7 +++++++ README.md | 2 +- lib/burnex.ex | 23 ++++++++++++++++++++--- mix.exs | 2 +- priv/burner-email-providers/emails.txt | 12 +++++++++++- test/burnex_test.exs | 5 ++++- 6 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1e80341 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +## 1.0.5 (2018-08-29) + +* Enhancements + - Add `is_burner_domain/1` function to check the domain directly + - Update providers list diff --git a/README.md b/README.md index ba1688b..b8ab1c2 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Build Status](https://travis-ci.org/Betree/burnex.svg?branch=master)](https://travis-ci.org/Betree/burnex) [![Coverage Status](https://coveralls.io/repos/github/Betree/burnex/badge.svg?branch=master)](https://coveralls.io/github/Betree/burnex?branch=master) -Compare an email address against 3700+ burner email domains (temporary email providers) based on +Compare an email address against 3900+ burner email domains (temporary email providers) based on [this list](https://github.com/wesbos/burner-email-providers). See [documentation](https://hexdocs.pm/burnex/Burnex.html). diff --git a/lib/burnex.ex b/lib/burnex.ex index 556cd1d..036e842 100644 --- a/lib/burnex.ex +++ b/lib/burnex.ex @@ -26,8 +26,8 @@ defmodule Burnex do @spec is_burner?(binary()) :: boolean() def is_burner?(email) do case Regex.run(~r/@([^@]+)$/, String.downcase(email)) do - [_ | [provider]] -> - Enum.any?(@providers, &Kernel.==(provider, &1)) + [_ | [domain]] -> + is_burner_domain(domain) _ -> # Bad email format @@ -35,11 +35,28 @@ defmodule Burnex do end end + @doc """ + Check a domain + + ## Examples + + iex> Burnex.is_burner_domain("yopmail.fr") + true + iex> Burnex.is_burner_domain("") + false + iex> Burnex.is_burner_domain("gmail.com") + false + """ + @spec is_burner_domain(binary()) :: boolean() + def is_burner_domain(domain) do + Enum.any?(@providers, &Kernel.==(domain, &1)) + end + @doc """ Returns the list of all blacklisted domains providers """ @spec providers() :: nonempty_list(binary()) - def providers() do + def providers do @providers end end diff --git a/mix.exs b/mix.exs index 92fa4b9..c0c09e3 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Burnex.Mixfile do def project do [ app: :burnex, - version: "1.0.4", + version: "1.0.5", elixir: "~> 1.6.6", description: "Elixir burner email (temporary address) detector", start_permanent: Mix.env == :prod, diff --git a/priv/burner-email-providers/emails.txt b/priv/burner-email-providers/emails.txt index bdde369..8525d83 100644 --- a/priv/burner-email-providers/emails.txt +++ b/priv/burner-email-providers/emails.txt @@ -1648,7 +1648,6 @@ icemovie.link ichigo.me icx.in icx.ro -id.au idigo.org ieatspam.eu ieatspam.info @@ -2449,6 +2448,7 @@ nfast.net nguyenusedcars.com nh3.ro nice-4u.com +nicemail.pro nicewoodenbaskets.com nicknassar.com nickrizos.com @@ -3899,3 +3899,13 @@ zxcv.com zxcvbnm.com zxcxc.com zzi.us +pay-mon.com +zep-hyr.com +travala10.com +zippiex.com +poly-swarm.com +1shivom.com +fidelium10.com +hubii-network.com +hurify1.com +bit-degree.com diff --git a/test/burnex_test.exs b/test/burnex_test.exs index 4886c82..0757f67 100644 --- a/test/burnex_test.exs +++ b/test/burnex_test.exs @@ -1,9 +1,12 @@ defmodule BurnexTest do + @moduledoc """ + Tests for `Burnex` module. + """ + use ExUnit.Case, async: true use ExUnitProperties doctest Burnex - test "example: filters jetable.org" do assert Burnex.is_burner? "test@jetable.org" end