From ef38881431b8edcbd76b4cb4fda1edd76ccde89f Mon Sep 17 00:00:00 2001 From: Borut Tomazin Date: Tue, 14 May 2024 12:13:42 +0200 Subject: [PATCH] Address PR comment. --- Sources/Apple/AppleAuthenticator+Models.swift | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Sources/Apple/AppleAuthenticator+Models.swift b/Sources/Apple/AppleAuthenticator+Models.swift index 22514d6..935eb49 100644 --- a/Sources/Apple/AppleAuthenticator+Models.swift +++ b/Sources/Apple/AppleAuthenticator+Models.swift @@ -22,12 +22,16 @@ public extension AppleAuthenticator { public let nameComponents: PersonNameComponents? public let email: Email public let expiresAt: Date - + + /// User full name represented by `givenName` and `familyName` public var name: String? { - let fullName = [nameComponents?.givenName, nameComponents?.familyName] - .compactMap { $0 } - .joined(separator: " ") - return !fullName.isEmpty ? fullName : nil + guard let givenName = nameComponents?.givenName else { + return nameComponents?.familyName + } + guard let familyName = nameComponents?.familyName else { + return givenName + } + return "\(givenName) \(familyName)" } }