File tree Expand file tree Collapse file tree 3 files changed +49
-8
lines changed Expand file tree Collapse file tree 3 files changed +49
-8
lines changed Original file line number Diff line number Diff line change 1+ import Foundation
2+ import RFC_1035
3+
4+ extension Domain {
5+ // Forward conversion already exists in Domain.swift
6+ // public init(rfc1035: RFC_1035.Domain) throws
7+ }
8+
9+ extension RFC_1035 . Domain {
10+ /// Initialize from Domain
11+ ///
12+ /// Enables round-trip conversion between Domain and RFC_1035.Domain.
13+ ///
14+ /// - Parameter domain: The Domain to convert
15+ /// - Throws: If the Domain doesn't have a valid RFC 1035 representation
16+ public init ( _ domain: Domain ) throws {
17+ guard let rfc1035 = domain. rfc1035 else {
18+ throw Domain . DomainError. conversionFailure
19+ }
20+ self = rfc1035
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ import Foundation
2+ import RFC_1123
3+
4+ extension Domain {
5+ // Forward conversion already exists in Domain.swift
6+ // public init(rfc1123: RFC_1123.Domain)
7+ }
8+
9+ extension RFC_1123 . Domain {
10+ /// Initialize from Domain
11+ ///
12+ /// Enables round-trip conversion between Domain and RFC_1123.Domain.
13+ ///
14+ /// - Parameter domain: The Domain to convert
15+ /// - Returns: The RFC 1123 domain representation
16+ /// - Note: Since RFC_5321.Domain is RFC_1123.Domain, this always succeeds
17+ public init ( _ domain: Domain ) {
18+ // RFC 5321 uses RFC 1123 domains directly, so we can always get an RFC 1123 representation
19+ self = domain. rfc5321
20+ }
21+ }
Original file line number Diff line number Diff line change @@ -52,21 +52,19 @@ extension Domain {
5252 }
5353
5454 /// Initialize from RFC1123
55- public init ( rfc1123: RFC_1123 . Domain ) throws {
55+ /// Note: RFC 5321 reuses RFC 1123 domain definitions, so this conversion is infallible
56+ public init ( rfc1123: RFC_1123 . Domain ) {
5657 self . rfc1035 = nil // RFC1123 may not be RFC1035 compliant
5758 self . rfc1123 = rfc1123
58- self . rfc5321 = try {
59- guard let domain = try ? RFC_5321 . Domain ( rfc1123. name) else {
60- throw DomainError . conversionFailure
61- }
62- return domain
63- } ( )
59+ // RFC 5321 uses RFC 1123 domains directly (type alias), so this is safe
60+ self . rfc5321 = rfc1123
6461 }
6562
6663 /// Initialize from RFC_5321.Domain
64+ /// Note: RFC_5321.Domain is actually a type alias for RFC_1123.Domain
6765 public init ( rfc5321: RFC_5321 . Domain ) {
6866 self . rfc1035 = nil // RFC_5321.Domain may not be RFC1035 compliant
69- self . rfc1123 = nil // RFC_5321.Domain may not be RFC1123 compliant
67+ self . rfc1123 = rfc5321 // RFC 5321 uses RFC 1123 domains
7068 self . rfc5321 = rfc5321
7169 }
7270}
You can’t perform that action at this time.
0 commit comments