urns

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2018 License: AGPL-3.0 Imports: 6 Imported by: 0

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"

	// WeChatScheme is the scheme used for WeChat identifiers
	WeChatScheme string = "wechat"

	// 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, error)

NewFirebaseURN returns a URN for the passed in firebase 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 NewWhatsAppURN

func NewWhatsAppURN(identifier string) (URN, error)

NewWhatsAppURN returns a URN for the passed in whatsapp identifier

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