Replaces '.Replace' calls with a Regex #72
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I removed the block of
.Replace
calls from theAddressExtractor
class.Not that this is a corporate environment with a bunch of people editing over eachother, but I wrote the filter system so that there wasn't a spaghetti mess of things overlapping (Including people trying to make overlapping edits). Each filter either accepts or denies an email as valid.
I replaced the block of Replaces with a new Filter, so if an address starts with an illegal character (
'!`{#\n\
) it'll trim them from the start. (Rather than a full replace).Then if there was a replace it'll return
REVALIDATE
which will refilter it against other filters to make sure it's still valid.With filters if one filter removes an illegal character, eg
-
, and another filter checks for valid domains, then you might have something where you pass in the email@my-test.dom-ain
. The first filter might remove our "illegal"-
character which results with@mytest.domain
, and then the second filter will deny.domain
for being an invalid TLD.For the remaining test you last added
EmailAddressesInExtracted
with the emailfoo|test@example.com|bar
, the Filter system needs to be modified because you can only currently return one modified Email address. A filter could see|
as an illegal character, run a.Split('|')
for["foo", "test@example.com", "bar"]
and then run each through the filter system again, wherefoo
andbar
would be skipped.