Skip to content

Commit 8af71b0

Browse files
committed
fix: enhance name splitting to handle 'Lastname, Firstname' format
Signed-off-by: Enjeck C. <patrathewhiz@gmail.com>
1 parent bff9aaf commit 8af71b0

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

apps/dav/lib/CardDAV/Converter.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ public function splitFullName(string $fullName): array {
161161
// Very basic western style parsing. I'm not gonna implement
162162
// https://github.com/android/platform_packages_providers_contactsprovider/blob/master/src/com/android/providers/contacts/NameSplitter.java ;)
163163

164+
// Handle "Lastname, Firstname" format
165+
if (str_contains($fullName, ',')) {
166+
[$family, $given] = array_map('trim', explode(',', $fullName, 2));
167+
if ($family !== '' && $given !== '') {
168+
return [$family, $given, '', '', ''];
169+
}
170+
}
171+
164172
$elements = explode(' ', $fullName);
165173
$result = ['', '', '', '', ''];
166174
if (count($elements) > 2) {

0 commit comments

Comments
 (0)