Skip to content

Commit 998ff19

Browse files
dab246hoangdat
authored andcommitted
TF-3539 Support separator list email with space character
Signed-off-by: dab246 <tdvu@linagora.com>
1 parent d2e2b5e commit 998ff19

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

core/lib/utils/string_convert.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:core/domain/exceptions/string_exception.dart';
66
import 'package:http_parser/http_parser.dart';
77

88
class StringConvert {
9-
static const String emailSeparatorPattern = r'[,;]+';
9+
static const String emailSeparatorPattern = r'[ ,;]+';
1010

1111
static String? writeEmptyToNull(String text) {
1212
if (text.isEmpty) return null;

core/test/utils/string_convert_test.dart

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void main() {
4545
group('Basic Functionality', () {
4646
test('should not extract strings separated by spaces', () {
4747
const input = 'user1@example.com user2@example.com';
48-
final expected = ['user1@example.com user2@example.com'];
48+
final expected = ['user1@example.com', 'user2@example.com'];
4949
expect(StringConvert.extractEmailAddress(input), equals(expected));
5050
});
5151

@@ -130,23 +130,29 @@ void main() {
130130
test('should handle URL encoded input', () {
131131
String input = 'user1%40example.com%20user2%40example.com%20user3%40example.com';
132132
final expected = [
133-
'user1@example.com user2@example.com user3@example.com'
133+
'user1@example.com',
134+
'user2@example.com',
135+
'user3@example.com'
134136
];
135137
expect(StringConvert.extractEmailAddress(input), equals(expected));
136138
});
137139

138140
test('should handle Base64 encoded input', () {
139141
String input = 'dXNlcjFAZXhhbXBsZS5jb20gdXNlcjJAZXhhbXBsZS5jb20gdXNlcjNAZXhhbXBsZS5jb20=';
140142
final expected = [
141-
'user1@example.com user2@example.com user3@example.com'
143+
'user1@example.com',
144+
'user2@example.com',
145+
'user3@example.com'
142146
];
143147
expect(StringConvert.extractEmailAddress(input), equals(expected));
144148
});
145149

146150
test('should handle input with both URL encoding and Base64 encoding', () {
147151
String input = Uri.encodeComponent(base64.encode(utf8.encode('user1@example.com user2@example.com user3@example.com')));
148152
final expected = [
149-
'user1@example.com user2@example.com user3@example.com'
153+
'user1@example.com',
154+
'user2@example.com',
155+
'user3@example.com'
150156
];
151157
expect(StringConvert.extractEmailAddress(input), equals(expected));
152158
});
@@ -182,7 +188,8 @@ void main() {
182188
// Arrange
183189
String input = 'user1@example.com\nuser2@example.com;user3@example.com';
184190
final expected = [
185-
'user1@example.com user2@example.com',
191+
'user1@example.com',
192+
'user2@example.com',
186193
'user3@example.com'
187194
];
188195
expect(StringConvert.extractEmailAddress(input), equals(expected));

0 commit comments

Comments
 (0)