diff --git a/README.md b/README.md index 926ce6f..d4e1873 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,12 @@ When your user types in "user@gmil.con", it will suggest "user@gmail.com". It is currently worth looking at the documentation at https://github.com/mailcheck/mailcheck -2015/12/30 -Thanks to https://github.com/Adrian2112 for a pull request, he created the mailparts -records based email splitter. I have retained splitemail call to make the version change -a Minor, but it now just uses the mailparts logic. +4.1.0 2015/12/30 + + Thanks to https://github.com/Adrian2112 for a pull request, he created the + `mailParts` functiion. I have retained `splitEmail` in API to make the version + hange a Minor, but it now just uses the mailParts logic. Adrian also + contributed a few refactors I have pulled in manually. Installation diff --git a/elm-package.json b/elm-package.json index b373335..f5340ad 100644 --- a/elm-package.json +++ b/elm-package.json @@ -1,5 +1,5 @@ { - "version": "4.0.0", + "version": "4.1.0", "summary": "Mailcheck suggest corrections to errors in email addresses", "repository": "https://github.com/rluiten/mailcheck.git", "license": "BSD3", diff --git a/src/Mailcheck.elm b/src/Mailcheck.elm index 9276445..da12bf1 100644 --- a/src/Mailcheck.elm +++ b/src/Mailcheck.elm @@ -34,6 +34,7 @@ This is a port of this javascript library https://github.com/mailcheck/mailcheck @docs encodeEmail @docs splitEmail @docs mailParts +@docs MailParts @docs findClosestDomain # Default domain lists used by suggest @@ -52,6 +53,7 @@ import StringDistance exposing (sift3Distance) import MaybeUtils exposing (thenAnd, thenOneOf) +{-| Record type alias for mailparts. -} type alias MailParts = { topLevelDomain : String, @@ -132,7 +134,7 @@ checkPartsNotInList secondLevelDomains topLevelDomains mailParts = closestDomain : List String -> MailParts -> Maybe (String, String, String) closestDomain domains mailParts = - let closestDomain = findClosestDomain domainThreshold mailParts.domain domains + let closestDomain = findClosestDomain mailParts.domain domains result closestDomain = Just (mailParts.address, closestDomain, mailParts.address ++ "@" ++ closestDomain) isDifferentDomain closestDomain = if closestDomain == mailParts.domain then @@ -149,7 +151,7 @@ closestSecondLevelDomain : List String -> List String -> MailParts -> Maybe (Str closestSecondLevelDomain secondLevelDomains topLevelDomains mailParts = let findClosest threshold domains = - findClosestDomain threshold domains + findClosestDomain domains findResultSld = findClosest secondLevelThreshold mailParts.secondLevelDomain secondLevelDomains findResultTld = findClosest topLevelThreshold mailParts.topLevelDomain topLevelDomains suggestedDomain = @@ -372,9 +374,9 @@ is equivalent to findClosestDomainWith sift3Distance topLevelThreshold "test@gmail.co" slds tlds ``` -} -findClosestDomain : Float -> String -> List String -> Maybe String -findClosestDomain threshold = - findClosestDomainWith sift3Distance threshold +findClosestDomain : String -> List String -> Maybe String +findClosestDomain = + findClosestDomainWith sift3Distance domainThreshold {-| Find closest domain in given list of domains using the diff --git a/tests/MailcheckTest.elm b/tests/MailcheckTest.elm index 8093e70..cef5c3b 100644 --- a/tests/MailcheckTest.elm +++ b/tests/MailcheckTest.elm @@ -98,7 +98,7 @@ runFcdTest name data = test input -- input String doubles as test name (assertEqual expect - (findClosestDomain 2.0 input domains) + (findClosestDomain input domains) ) ) data