-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #460 from chriso/chriso/configurable-email-normali…
…zation Configurable GMail address normalization
- Loading branch information
Showing
3 changed files
with
30 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,7 @@ $ bower install validator-js | |
- **blacklist(input, chars)** - remove characters that appear in the blacklist. The characters are used in a RegExp and so you will need to escape some chars, e.g. `blacklist(input, '\\[\\]')`. | ||
- **escape(input)** - replace `<`, `>`, `&`, `'`, `"` and `/` with HTML entities. | ||
- **ltrim(input [, chars])** - trim characters from the left-side of the input. | ||
- **normalizeEmail(email [, options])** - canonicalize an email address. `options` is an object which defaults to `{ lowercase: true }`. With `lowercase` set to `true`, the local part of the email address is lowercased for all domains; the hostname is always lowercased and the local part of the email address is always lowercased for hosts that are known to be case-insensitive (currently only GMail). Normalization follows special rules for known providers: currently, GMail addresses have dots removed in the local part and are stripped of tags (e.g. `[email protected]` becomes `[email protected]`) and all `@googlemail.com` addresses are normalized to `@gmail.com`. | ||
- **normalizeEmail(email [, options])** - canonicalize an email address. `options` is an object which defaults to `{ lowercase: true, remove_dots: true, remove_extension: true }`. With `lowercase` set to `true`, the local part of the email address is lowercased for all domains; the hostname is always lowercased and the local part of the email address is always lowercased for hosts that are known to be case-insensitive (currently only GMail). Normalization follows special rules for known providers: currently, GMail addresses have dots removed in the local part and are stripped of tags (e.g. `[email protected]` becomes `[email protected]`) and all `@googlemail.com` addresses are normalized to `@gmail.com`. | ||
- **rtrim(input [, chars])** - trim characters from the right-side of the input. | ||
- **stripLow(input [, keep_new_lines])** - remove characters with a numerical value < 32 and 127, mostly control characters. If `keep_new_lines` is `true`, newline characters are preserved (`\n` and `\r`, hex `0xA` and `0xD`). Unicode-safe in JavaScript. | ||
- **toBoolean(input [, strict])** - convert the input to a boolean. Everything except for `'0'`, `'false'` and `''` returns `true`. In strict mode only `'1'` and `'true'` return `true`. | ||
|
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,7 +198,9 @@ describe('Sanitizers', function () { | |
, 'an invalid email address': false | ||
, '': false | ||
, '[email protected]': false | ||
// [email protected] was removed from test cases because of a bug with validator.isEmail. See issue #258 | ||
, '[email protected]': false | ||
, '[email protected]': false | ||
, '[email protected]': '[email protected]' | ||
} | ||
}); | ||
test({ | ||
|
@@ -211,13 +213,27 @@ describe('Sanitizers', function () { | |
, '[email protected]': '[email protected]' | ||
, '[email protected]': '[email protected]' | ||
, '[email protected]': '[email protected]' | ||
|
||
// Domains that are known for being case-insensitive are always lowercased | ||
, '[email protected]': '[email protected]' | ||
, '[email protected]': '[email protected]' | ||
, '[email protected]': '[email protected]' | ||
} | ||
}); | ||
test({ | ||
sanitizer: 'normalizeEmail' | ||
, args: [{remove_dots: false}] | ||
, expect: { | ||
'[email protected]': '[email protected]' | ||
} | ||
}); | ||
test({ | ||
sanitizer: 'normalizeEmail' | ||
, args: [{remove_extension: false}] | ||
, expect: { | ||
'[email protected]': '[email protected]' | ||
} | ||
}); | ||
}); | ||
|
||
}); |
This file contains 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 characters