gristlabs_grist-core/app/common/emails.ts
Paul Fitzpatrick 5ef889addd (core) move home server into core
Summary: This moves enough server material into core to run a home server.  The data engine is not yet incorporated (though in manual testing it works when ported).

Test Plan: existing tests pass

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2552
2020-07-21 20:39:10 -04:00

44 lines
1.4 KiB
TypeScript

/**
*
* Utilities related to email normalization. Currently
* trivial, but could potentially need special per-domain
* rules in future.
*
* Email addresses are a bit slippery. Domain names are
* case insensitive, but user names may or may not be,
* depending on the mail server handling the domain.
* Other special treatment of user names may also be in
* place for particular domains (periods, plus sign, etc).
*
* We treat emails as case-insensitive for the purposes
* of determining equality of emails, and indexing users
* by email address.
*
*/
/**
*
* Convert the supplied email address to a normalized form
* that we will use for indexing and equality tests.
* Many possible email addresses could map to the same
* normalized result; as far as we are concerned those
* addresses are equivalent.
*
* The normalization we do is a simple lowercase. This
* means we won't be able to treat both Jane@x.y and
* jane@x.y as separate email addresses, even through
* they may in fact be separate mailboxes on x.y.
*
* The normalized email is not something we should show
* the user in the UI, but is rather for internal purposes.
*
* The original non-normalized email is called a
* "display email" to distinguish it from a "normalized
* email"
*
*/
export function normalizeEmail(displayEmail: string): string {
// We take the lower case, without use of locale.
return displayEmail.toLowerCase();
}