Releases: swift-standards/swift-domain-standard
Releases · swift-standards/swift-domain-standard
v0.0.1
Swift Domain Type v0.0.1
Initial release of swift-domain-type, a Swift domain model for domain names compliant with web standards.
Features
- Unified Domain Type: Supports RFC 1035, RFC 1123, and RFC 5321 domain standards
- Domain Validation: Automatic validation and format detection across different RFC requirements
- Subdomain Operations: Create, validate, and manage subdomain relationships
- Parent/Child Relationships: Navigate domain hierarchies with
parent()andisSubdomain(of:)methods - Protocol Conformance: Implements
Codable,RawRepresentable, andCustomStringConvertible
API Overview
Basic Usage
import Domain
// Create a domain
let domain = try Domain("example.com")
print(domain.name) // "example.com"
print(domain.tld) // "com"
print(domain.sld) // "example"
// Subdomain operations
let subdomain = try domain.addingSubdomain("mail")
print(subdomain.name) // "mail.example.com"
print(subdomain.isSubdomain(of: domain)) // true
// Parent domain
let parent = try subdomain.parent()
print(parent?.name) // "example.com"RFC-Specific Creation
import RFC_1035
import RFC_1123
import RFC_5321
// Create from specific RFC types
let rfc1035 = try RFC_1035.Domain("example.com")
let domain1 = try Domain(rfc1035: rfc1035)
let rfc1123 = try RFC_1123.Domain("host.example.com")
let domain2 = try Domain(rfc1123: rfc1123)
let rfc5321 = try RFC_5321.Domain("mail.example.com")
let domain3 = Domain(rfc5321: rfc5321)Testing
The package includes a comprehensive test suite with 53 tests covering:
- Domain creation and validation
- RFC-specific functionality
- Subdomain operations
- Error handling
- Protocol conformances
Run tests with:
swift testRequirements
- Swift 6.0+
- macOS 13.0+ / iOS 16.0+
Dependencies
Installation
Swift Package Manager
Add to your Package.swift:
dependencies: [
.package(url: "https://github.com/coenttb/swift-domain-type", from: "0.0.1")
]