getMatchingEmail static method
Checks if both email addresses original and check match and
returns the match.
Set allowPlusAlias if plus aliases should be checked, so that
name+alias@domain matches the original name@domain.
Implementation
static String? getMatchingEmail(
String original,
String check, {
bool allowPlusAlias = false,
}) {
if (check == original) {
return check;
} else if (allowPlusAlias) {
final plusIndex = check.indexOf('+');
if (plusIndex > 1) {
final start = check.substring(0, plusIndex);
if (original.startsWith(start)) {
final atIndex = check.lastIndexOf('@');
if (atIndex > plusIndex &&
original.endsWith(check.substring(atIndex))) {
return check;
}
}
}
}
return null;
}