Last active
August 29, 2015 14:04
Revisions
-
9point6 revised this gist
Jul 22, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ defaultOptions = 'stripComments': true class EmailNormalizer constructor: ( @email, options = {} ) -> @options = defaultOptions for own k, v of options @options[k] = v -
9point6 revised this gist
Jul 22, 2014 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,6 +36,4 @@ class EmailNormalizer @normalized = out ( module?.exports or window?.EmailNormalizer ) = EmailNormalizer -
9point6 renamed this gist
Jul 22, 2014 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,17 @@ defaultOptions = 'normalizeGmail': true 'lowerCaseLocal': true 'stripTags': true 'stripComments': true class EmailNormalizer constructor: (@email, options = {}) -> @options = defaultOptions for own k, v of options @options[k] = v normalize: ( ) -> return @normalized if @normalized out = @email @@ -24,7 +24,7 @@ class EmailNormaliser if @options.stripComments out = out.replace /^((\([^)]*\))?)([^@]+)((\([^)]*\))?)\@/, '$3@' if @options.normalizeGmail out = out.split '@' if out[1] is 'googlemail.com' @@ -34,8 +34,8 @@ class EmailNormaliser out = out.join '@' @normalized = out # Node JS if module? module.exports = EmailNormalizer -
9point6 created this gist
Jul 22, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ defaultOptions = 'normaliseGmail': true 'lowerCaseLocal': true 'stripTags': true 'stripComments': true class EmailNormaliser constructor: (@email, options = {}) -> @options = defaultOptions for own k, v of options @options[k] = v normalise: ( ) -> return @normalised if @normalised out = @email if @options.lowerCaseLocal out = out.toLowerCase( ) if @options.stripTags out = out.replace /^([^+]+)(\+[^@]*)/, '$1' if @options.stripComments out = out.replace /^((\([^)]*\))?)([^@]+)((\([^)]*\))?)\@/, '$3@' if @options.normaliseGmail out = out.split '@' if out[1] is 'googlemail.com' out[1] = 'gmail.com' out[0] = out[0].replace /\./g, '' out = out.join '@' @normalised = out # Node JS if module? module.exports = EmailNormaliser