Documentation
¶
Index ¶
- Constants
- Variables
- func IsAlphaNum(r rune) bool
- func NormalizeNID(nid string) string
- func PeekPrefixFComponent(str string) (fcomponent string, n int, found bool)
- func PeekPrefixNID(str string) (n int, found bool)
- func PeekPrefixNSS(str string) (nss string, n int, found bool)
- func PeekPrefixPChar(str string) (byte, int, bool)
- func PeekPrefixQComponent(str string) (rcomponent string, n int, found bool)
- func PeekPrefixRComponent(str string) (rcomponent string, n int, found bool)
Constants ¶
const Scheme = "urn"
Scheme is the URI scheme of a URN.
The URI scheme of a URN is always "urn".
Variables ¶
var NIDs = []string{
"3gpp",
"3gpp2",
"adid",
"alert",
"bbf",
"broadband-forum-org",
"c2pa",
"cablelabs",
"ccsds",
"cdx",
"cgi",
"clei",
"csa",
"cta",
"ddi",
"dev",
"dgiwg",
"doi",
"dslforum-org",
"dvb",
"ebu",
"eic",
"eidr",
"epc",
"epcglobal",
"etsi",
"eurosystem",
"example",
"fdc",
"fipa",
"gdst",
"geant",
"globus",
"gsma",
"gvat",
"hbbtv",
"ieee",
"ietf",
"iptc",
"isan",
"isbn",
"iso",
"issn",
"itu",
"ivis",
"knx",
"lei",
"lex",
"liberty",
"mace",
"mef",
"meta",
"mpeg",
"mrn",
"nan",
"nato",
"nbn",
"nena",
"newsml",
"nfc",
"nzl",
"oasis",
"ogc",
"ogf",
"oid",
"oipf",
"oma",
"onem2m",
"onf",
"pin",
"pno",
"publicid",
"pwid",
"reso",
"s1000d",
"schac",
"service",
"smpte",
"stalwart",
"swift",
"thread",
"tva",
"uci",
"ucode",
"uic",
"uuid",
"web3d",
"wmo",
"xmlorg",
"xmpp",
}
NIDs is a list of registered URN NIDs, taken from:
https://www.iana.org/assignments/urn-namespaces/urn-namespaces.xhtml
... when it was last updated on:
2025-07-02
Functions ¶
func IsAlphaNum ¶
IsAlphaNum return 'true' if the rune is an "alphanum" as defined by IETF RFC-8141, and returns 'false' otherwise.
IETF RFC-8141 imports the definition of "alphanum" from IETF RFC-3986.
For example:
result := rfc8141.IsAlphaNum("E")
// result == true
And also, for example:
result := rfc8141.IsAlphaNum("-")
// result == false
func NormalizeNID ¶
NormalizeNID returns the normalized form of an NID (Namespace Identifier).
From IETF RFC-8141:
"NIDs are case insensitive (e.g., "ISBN" and "isbn" are equivalent)."
Normalization lower-cases chracter 'A' through 'Z' to 'a' through 'z'.
func PeekPrefixFComponent ¶
PeekPrefixFComponent looks at `str` and if it starts (and ends) with a fragment, as defined by IETF RFC-3986, then it returns it (without the '#' prefix).
PeekPrefixFComponent expects `str` to start with a '#', but the '#' is not returns as part of `fragment`. `n` includes the length of '#'.
IETF RFC-3986 defines 'fragment' as follows:
A fragment identifier component is indicated by
the presence of a number sign ("#") character and
terminated by the end of the URI.
fragment = *( pchar / "/" / "?" )
func PeekPrefixNID ¶
PeekPrefixNID looks to see if `str` begins with an NID (Namespace Identifier), and if it does, then return its length.
IETF RFC-8141 defines an NID (Namespace Identifier) as follows:
NID = (alphanum) 0*30(ldh) (alphanum) ldh = alphanum / "-"
func PeekPrefixNSS ¶
PeekPrefixNSS looks to see if `str` begins with an NSS (Namespace Specific String), and if it does, then returns the decoded NSS (Namespace Specific String) its original (encoded) length.
IETF RFC-8141 defines an NSS (Namespace Specific String) as follows:
NSS = pchar *(pchar / "/")
func PeekPrefixPChar ¶
PeekPrefixPChar peeks a string, checks to see if it starts with a 'pchar' (as defined in IETF RFC-3986), and returns it if it does.
'pchar' is defined in IETF RFC-3986 as:
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
func PeekPrefixQComponent ¶
PeekPrefixQComponent looks to see if `str` begins with an q-component (without the "?=" prefix), and if it does, then returns the decoded q-component and its original (encoded) length.
Notet that PeekPrefixQComponent expectd the "?+" to be there.
IETF RFC-8141 defines an q-component as follows:
rq-components = [ "?+" r-component ]
[ "?=" q-component ]
q-component = pchar *( pchar / "/" / "?" )
func PeekPrefixRComponent ¶
PeekPrefixRComponent looks to see if `str` begins with an r-component (without the "?+" prefix), and if it does, then returns the decoded r-component and its original (encoded) length.
Notet that PeekPrefixRComponent expectd the "?+" to be there.
IETF RFC-8141 defines an r-component as follows:
rq-components = [ "?+" r-component ]
[ "?=" q-component ]
r-component = pchar *( pchar / "/" / "?" )
Types ¶
This section is empty.