AddressURL

1.0.1

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

What's New

Version 1.0.1

2022-01-06T22:43:02Z

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: Sat Jan 15 2022 16:03:04 GMT-0500 (GMT-05:00)