Skip to content

twodayslate/AddressURL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Useful extension for URL to support IP and email addresses

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages