AddressURL

1.0.2

Useful extension for URL to support IP and email addresses
twodayslate/AddressURL

What's New

Version 1.0.2

2022-08-20T02:26:31Z

AddressURL

A simple Swift Package that extends URL with some helpful functions for IP and email address

Requires iOS 12.0+ since the Network API is used.

For domain information check out TLDExtractSwift.

Usage

IP Address can be converted to URLs

IPv4Address("8.8.8.8").url.with(component: .scheme("https")!.absoluteString // https://8.8.8.8
IPv6Address("::").url.with(component: .scheme("https")!.absoluteString // https://[::]

Alternativly you can get an IP Address from a URL

let url = URL(string: "https://8.8.8.8")
url.ipv4Address // 8.8.8.8

let url2 = URL(string: "https://[::]")
url.ipv6Address // ::

Specific URLComponents can be changed

let url = URL(string: "https://zac.gorak.us")
url.with(component: .scheme("ftp") // ftp://zac.gorak.us

Email addresses

let url = URL(email: "hello@gorak.us")
url.absoluteString // mailto://hello@gorak.us
url.emailAddress // hello@gorak.us

Email address parsing is handled by EmailValidator

Description

  • Swift Tools 5.1.0
View More Packages from this Author

Dependencies

Last updated: Fri Oct 18 2024 12:27:09 GMT-0900 (Hawaii-Aleutian Daylight Time)