Skip to content

Commit 324b0fc

Browse files
committed
Update to use LocalPart.description instead of stringValue
- Use .description property from CustomStringConvertible protocol - More idiomatic Swift (like URL.description vs URL.absoluteString) - Follows updated RFC package APIs
1 parent c4ce849 commit 324b0fc

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

Sources/EmailAddress/EmailAddress+RFC2822.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ extension RFC_2822.AddrSpec {
2121
// Try to use RFC 5322 representation if available (most compatible)
2222
if let rfc5322 = emailAddress.rfc5322 {
2323
try self.init(
24-
localPart: rfc5322.localPart.stringValue,
24+
localPart: rfc5322.localPart.description,
2525
domain: rfc5322.domain.name
2626
)
2727
} else {
2828
// Fall back to RFC 6531 (most permissive)
2929
try self.init(
30-
localPart: emailAddress.rfc6531.localPart.stringValue,
30+
localPart: emailAddress.rfc6531.localPart.description,
3131
domain: emailAddress.rfc6531.domain.name
3232
)
3333
}

Sources/EmailAddress/EmailAddress.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,13 @@ extension EmailAddress {
9090

9191
/// The local part (before @)
9292
public var localPart: String {
93-
rfc5321?.localPart.stringValue ?? rfc5322?.localPart.stringValue
94-
?? rfc6531.localPart.stringValue
93+
if let rfc5321 = rfc5321 {
94+
return rfc5321.localPart.description
95+
}
96+
if let rfc5322 = rfc5322 {
97+
return rfc5322.localPart.description
98+
}
99+
return rfc6531.localPart.description
95100
}
96101
}
97102

Sources/EmailAddress/RFC_5321+RFC_5322.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extension RFC_5321.EmailAddress {
1313
public init(_ rfc5322: RFC_5322.EmailAddress) throws {
1414
try self.init(
1515
displayName: rfc5322.displayName,
16-
localPart: .init(rfc5322.localPart.stringValue),
16+
localPart: .init(rfc5322.localPart.description),
1717
domain: rfc5322.domain
1818
)
1919
}
@@ -30,7 +30,7 @@ extension RFC_5322.EmailAddress {
3030
public init(_ rfc5321: RFC_5321.EmailAddress) throws {
3131
try self.init(
3232
displayName: rfc5321.displayName,
33-
localPart: .init(rfc5321.localPart.stringValue),
33+
localPart: .init(rfc5321.localPart.description),
3434
domain: rfc5321.domain
3535
)
3636
}

Sources/EmailAddress/RFC_5321+RFC_6531.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extension RFC_5321.EmailAddress {
1414
public init(_ rfc6531: RFC_6531.EmailAddress) throws {
1515
try self.init(
1616
displayName: rfc6531.displayName,
17-
localPart: .init(rfc6531.localPart.stringValue),
17+
localPart: .init(rfc6531.localPart.description),
1818
domain: .init(rfc6531.domain.name)
1919
)
2020
}
@@ -31,7 +31,7 @@ extension RFC_6531.EmailAddress {
3131
public init(_ rfc5321: RFC_5321.EmailAddress) throws {
3232
try self.init(
3333
displayName: rfc5321.displayName,
34-
localPart: .init(rfc5321.localPart.stringValue),
34+
localPart: .init(rfc5321.localPart.description),
3535
domain: rfc5321.domain
3636
)
3737
}

Sources/EmailAddress/RFC_5322+RFC_6531.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extension RFC_5322.EmailAddress {
1313
public init(_ rfc6531: RFC_6531.EmailAddress) throws {
1414
try self.init(
1515
displayName: rfc6531.displayName,
16-
localPart: .init(rfc6531.localPart.stringValue),
16+
localPart: .init(rfc6531.localPart.description),
1717
domain: rfc6531.domain
1818
)
1919
}
@@ -30,7 +30,7 @@ extension RFC_6531.EmailAddress {
3030
public init(_ rfc5322: RFC_5322.EmailAddress) throws {
3131
try self.init(
3232
displayName: rfc5322.displayName,
33-
localPart: .init(rfc5322.localPart.stringValue),
33+
localPart: .init(rfc5322.localPart.description),
3434
domain: rfc5322.domain
3535
)
3636
}

0 commit comments

Comments
 (0)