Skip to content

Commit

Permalink
Not fooled anymore by uppercase domains
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Jan 20, 2018
1 parent f4886a8 commit d1fd8b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/burnex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule Burnex do
"""
@spec is_burner?(String.t) :: boolean()
def is_burner?(email) do
case Regex.run(~r/@([^@]+)$/, email) do
case Regex.run(~r/@([^@]+)$/, String.downcase(email)) do
[_ | [provider]] ->
Enum.any?(@providers, &Kernel.==(provider, &1))
_ ->
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Burnex.Mixfile do
def project do
[
app: :burnex,
version: "1.0.0",
version: "1.0.1",
elixir: "~> 1.5",
description: "Elixir burner email (temporary address) detector",
start_permanent: Mix.env == :prod,
Expand Down
10 changes: 10 additions & 0 deletions test/burnex_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ defmodule BurnexTest do
refute Enum.any?(Burnex.providers, &(String.length(&1) == 0))
end

test "providers should always be lowercase" do
refute Enum.any?(Burnex.providers, &(String.downcase(&1) != &1))
end

property "doesn't explode if email has bad format" do
check all email <- StreamData.string(:alphanumeric) do
refute Burnex.is_burner? email
Expand All @@ -39,6 +43,12 @@ defmodule BurnexTest do
end
end

property "is not fooled by uppercase domains" do
check all email <- email_generator(Burnex.providers) do
assert Burnex.is_burner? String.upcase(email)
end
end

@valid_providers ["gmail.com", "live.fr", "protonmail.com", "outlook.com"]
property "should always return false for valid providers" do
check all email <- email_generator(@valid_providers) do
Expand Down

0 comments on commit d1fd8b4

Please sign in to comment.