crossmintNormalizeEmail function

String crossmintNormalizeEmail(
  1. String email
)

Normalizes an email the way the backend does before it stores a signer, so a caller's spelling and the stored method derive the same locator.

Mirrors normalizeEmail in crossbit-main (libraries/common/utils) and its port in the TypeScript SDK: the whole address is lowercased, googlemail.com becomes gmail.com, and a Gmail local part loses its dots. An address with no domain is only lowercased, because the backend rejects it long before it can become a recovery method.

Implementation

String crossmintNormalizeEmail(String email) {
  final String lower = email.trim().toLowerCase();
  final int at = lower.indexOf('@');
  if (at <= 0 || at == lower.length - 1) {
    return lower;
  }
  final String local = lower.substring(0, at);
  final String domain = lower.substring(at + 1);
  if (domain != 'gmail.com' && domain != 'googlemail.com') {
    return lower;
  }
  return '${local.replaceAll('.', '')}@gmail.com';
}