Documentation ¶
Index ¶
- Constants
- Variables
- func IsValidScheme(scheme string) bool
- func ParseNumber(s, country string) (string, error)
- type URN
- func NewDiscordURN(identifier string) (URN, error)
- func NewFacebookURN(identifier string) (URN, error)
- func NewFirebaseURN(identifier string) (URN, error)
- func NewInstagramURN(identifier string) (URN, error)
- func NewTelURNForCountry(number string, country string) (URN, error)
- func NewTelegramURN(identifier int64, display string) (URN, error)
- func NewURNFromParts(scheme string, path string, query string, display string) (URN, error)
- func NewWebChatURN(identifier string) (URN, error)
- func NewWhatsAppURN(identifier string) (URN, error)
- func Parse(s string) (URN, error)
- func (u URN) Display() string
- func (u URN) FacebookRef() string
- func (u URN) Format() string
- func (u URN) Identity() URN
- func (u URN) IsFacebookRef() bool
- func (u URN) Localize(country string) URN
- func (u URN) Normalize(country string) URN
- func (u URN) Path() string
- func (u URN) Query() (url.Values, error)
- func (u URN) RawQuery() string
- func (u URN) Scheme() string
- func (u URN) String() string
- func (u URN) ToParts() (string, string, string, string)
- func (u URN) Validate() error
Constants ¶
const ( DiscordScheme string = "discord" // (user IDs not usernames) EmailScheme string = "mailto" ExternalScheme string = "ext" FacebookScheme string = "facebook" FCMScheme string = "fcm" FreshChatScheme string = "freshchat" InstagramScheme string = "instagram" JiochatScheme string = "jiochat" LineScheme string = "line" RocketChatScheme string = "rocketchat" SlackScheme string = "slack" TelegramScheme string = "telegram" TelScheme string = "tel" TwitterIDScheme string = "twitterid" // Twitter user ids TwitterScheme string = "twitter" // Twitter handles ViberScheme string = "viber" VKScheme string = "vk" WebChatScheme string = "webchat" WeChatScheme string = "wechat" WhatsAppScheme string = "whatsapp" // FacebookRefPrefix is prefix used for facebook referral URNs FacebookRefPrefix string = "ref:" )
Variables ¶
var NilURN = URN("")
NilURN is our constant for nil URNs
var ValidSchemes = map[string]bool{ DiscordScheme: true, EmailScheme: true, ExternalScheme: true, FacebookScheme: true, FCMScheme: true, FreshChatScheme: true, InstagramScheme: true, JiochatScheme: true, LineScheme: true, RocketChatScheme: true, SlackScheme: true, TelegramScheme: true, TelScheme: true, TwitterIDScheme: true, TwitterScheme: true, ViberScheme: true, VKScheme: true, WebChatScheme: true, WeChatScheme: true, WhatsAppScheme: true, }
ValidSchemes is the set of URN schemes understood by this library
Functions ¶
func IsValidScheme ¶
IsValidScheme checks whether the provided scheme is valid
func ParseNumber ¶
ParseNumber tries to parse the given string as a phone number and if successful returns it as E164
Types ¶
type URN ¶
type URN string
URN represents a Universal Resource Name, we use this for contact identifiers like phone numbers etc..
func NewDiscordURN ¶
NewDiscordURN returns a URN for the passed in Discord identifier
func NewFacebookURN ¶
NewFacebookURN returns a URN for the passed in facebook identifier
func NewFirebaseURN ¶
NewFirebaseURN returns a URN for the passed in firebase identifier
func NewInstagramURN ¶
NewInstagramURN returns a URN for the passed in instagram identifier
func NewTelURNForCountry ¶
NewTelURNForCountry returns a URN for the passed in telephone number and country code ("US")
func NewTelegramURN ¶
NewTelegramURN returns a URN for the passed in telegram identifier
func NewURNFromParts ¶
NewURNFromParts returns a validated URN for the given scheme, path, query and display
func NewWebChatURN ¶
func NewWhatsAppURN ¶
NewWhatsAppURN returns a URN for the passed in whatsapp identifier
func Parse ¶
Parse parses a URN from the given string. The returned URN is only guaranteed to be structurally valid.
func (URN) FacebookRef ¶
FacebookRef returns the facebook referral portion of our path, this return empty string in the case where we aren't a Facebook scheme
func (URN) IsFacebookRef ¶
IsFacebookRef returns whether this URN is a facebook referral
func (URN) Normalize ¶
Normalize normalizes the URN into it's canonical form and should be performed before URN comparisons