TF-3864 Support pasting address with display name
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:core/domain/exceptions/string_exception.dart';
|
||||
import 'package:core/utils/mail/named_address.dart';
|
||||
import 'package:html/parser.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
|
||||
@@ -137,4 +138,16 @@ class StringConvert {
|
||||
log('StringConvert::isTextTable:isMarkdown = $isMarkdown | isAscii = $isAsciiArt');
|
||||
return isMarkdown || isAsciiArt;
|
||||
}
|
||||
|
||||
static NamedAddress? parseNamedAddress(String input) {
|
||||
final regex = RegExp(r'''^(['"])(.+?)\1\s*<([^>\s]+)>$''');
|
||||
final match = regex.firstMatch(input.trim());
|
||||
if (match != null) {
|
||||
final name = match.group(2)!;
|
||||
final address = match.group(3)!;
|
||||
|
||||
return NamedAddress(name: name, address: address);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user