urns

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2018 License: AGPL-3.0 Imports: 5 Imported by: 132

Documentation

Index

Constants

View Source
const (
	// EmailScheme is the scheme used for email addresses
	EmailScheme string = "mailto"

	// ExternalScheme is the scheme used for externally defined identifiers
	ExternalScheme string = "ext"

	// FacebookScheme is the scheme used for Facebook identifiers
	FacebookScheme string = "facebook"

	// FCMScheme is the scheme used for Firebase Cloud Messaging identifiers
	FCMScheme string = "fcm"

	// JiochatScheme is the scheme used for Jiochat identifiers
	JiochatScheme string = "jiochat"

	// LineScheme is the scheme used for LINE identifiers
	LineScheme string = "line"

	// TelegramScheme is the scheme used for Telegram identifiers
	TelegramScheme string = "telegram"

	// TelScheme is the scheme used for telephone numbers
	TelScheme string = "tel"

	// TwitterIDScheme is the scheme used for Twitter user ids
	TwitterIDScheme string = "twitterid"

	// TwitterScheme is the scheme used for Twitter handles
	TwitterScheme string = "twitter"

	// ViberScheme is the scheme used for Viber identifiers
	ViberScheme string = "viber"

	// WhatsAppScheme is the scheme used for WhatsApp identifiers
	WhatsAppScheme string = "whatsapp"

	// FacebookRefPrefix is the path 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

Types

type URN

type URN string

URN represents a Universal Resource Name, we use this for contact identifiers like phone numbers etc..

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

NewFirebaseURN returns a URN for the passed in firebase identifier

func NewTelURNForCountry

func NewTelURNForCountry(number string, country string) URN

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

func NewTelegramURN

func NewTelegramURN(identifier int64, display string) URN

NewTelegramURN returns a URN for the passed in telegram identifier

func NewURNFromParts

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

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

func NewWhatsAppURN

func NewWhatsAppURN(identifier string) (URN, error)

NewWhatsAppURN returns a URN for the passed in whatsapp identifier

func (URN) Default

func (u URN) Default() interface{}

Default is called when a URN is part of an excellent expression

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() string

Identity returns the URN with any 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) Resolve

func (u URN) Resolve(key string) interface{}

Resolve is called when a URN is part of an excellent expression

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)

ToParts splits the URN into scheme, path and display parts

func (URN) Validate

func (u URN) Validate() bool

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