urns

package
v0.0.0-...-a852ce6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
var NilURN = URN("")

NilURN is our constant for nil URNs

ValidSchemes is the set of URN schemes understood by this library

Functions

func IsValidScheme

func IsValidScheme(scheme string) bool

IsValidScheme checks whether the provided scheme is valid

func ParseNumber

func ParseNumber(s, country string) (string, error)

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

func NewDiscordURN(identifier string) (URN, error)

NewDiscordURN returns a URN for the passed in Discord identifier

func NewFacebookURN

func NewFacebookURN(identifier string) (URN, error)

NewFacebookURN returns a URN for the passed in facebook identifier

func NewFirebaseURN

func NewFirebaseURN(identifier string) (URN, error)

NewFirebaseURN returns a URN for the passed in firebase identifier

func NewInstagramURN

func NewInstagramURN(identifier string) (URN, error)

NewInstagramURN returns a URN for the passed in instagram identifier

func NewTelURNForCountry

func NewTelURNForCountry(number string, country string) (URN, error)

NewTelURNForCountry returns a URN for the passed in telephone number and country code ("US")

func NewTelegramURN

func NewTelegramURN(identifier int64, display string) (URN, error)

NewTelegramURN returns a URN for the passed in telegram identifier

func NewURNFromParts

func NewURNFromParts(scheme string, path string, query string, display string) (URN, error)

NewURNFromParts returns a validated URN for the given scheme, path, query and display

func NewWebChatURN

func NewWebChatURN(identifier string) (URN, error)

func NewWhatsAppURN

func NewWhatsAppURN(identifier string) (URN, error)

NewWhatsAppURN returns a URN for the passed in whatsapp identifier

func Parse

func Parse(s string) (URN, error)

Parse parses a URN from the given string. The returned URN is only guaranteed to be structurally valid.

func (URN) Display

func (u URN) Display() string

Display returns the display portion for the URN (if any)

func (URN) FacebookRef

func (u URN) FacebookRef() string

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) Format

func (u URN) Format() string

Format formats this URN as a human friendly string

func (URN) Identity

func (u URN) Identity() URN

Identity returns the URN with any query or display attributes stripped

func (URN) IsFacebookRef

func (u URN) IsFacebookRef() bool

IsFacebookRef returns whether this URN is a facebook referral

func (URN) Localize

func (u URN) Localize(country string) URN

Localize returns a new URN which is local to the given country

func (URN) Normalize

func (u URN) Normalize(country string) URN

Normalize normalizes the URN into it's canonical form and should be performed before URN comparisons

func (URN) Path

func (u URN) Path() string

Path returns the path portion for the URN

func (URN) Query

func (u URN) Query() (url.Values, error)

Query returns the parsed query portion for the URN (if any)

func (URN) RawQuery

func (u URN) RawQuery() string

RawQuery returns the unparsed query portion for the URN (if any)

func (URN) Scheme

func (u URN) Scheme() string

Scheme returns the scheme portion for the URN

func (URN) String

func (u URN) String() string

String returns the string representation of this URN

func (URN) ToParts

func (u URN) ToParts() (string, string, string, string)

ToParts splits the URN into scheme, path and display parts

func (URN) Validate

func (u URN) Validate() error

Validate returns whether this URN is considered valid

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL