Documentation
¶
Index ¶
- Constants
- func DecodePctEncoded(b2 byte, b3 byte) (byte, error)
- func HasPrefixPctEncoded(str string) bool
- func IsAlpha(r rune) bool
- func IsAlphaNum(r rune) bool
- func IsDigit(r rune) bool
- func IsGenDelim(r rune) bool
- func IsHexDig(r rune) bool
- func IsPctEncodedPrefix(r rune) bool
- func IsReserved(r rune) bool
- func IsSubDelim(r rune) bool
- func IsUnreserved(r rune) bool
- func PeekPrefixFragment(str string) (fragment string, n int, found bool)
- func PeekPrefixPChar(str string) (byte, int, bool)
- func PeekPrefixPctEncoded(str string) (byte, int, bool)
- func PeekPrefixScheme(str string) (scheme string, n int, found bool)
- func PeekPrefixSubDelims(str string) (byte, int, bool)
- func PeekPrefixUnreserved(str string) (byte, int, bool)
- func ReadPctEncodedByte(reader io.Reader) (byte, error)
- func ReadScheme(reader io.Reader) (string, error)
- func ValidateScheme(scheme string) error
- func WritePctEncodedByte(writer io.Writer, b byte) error
Constants ¶
const SchemeTerminator = ':'
Variables ¶
This section is empty.
Functions ¶
func DecodePctEncoded ¶
DecodePctEncoded decodes the 2nd and 3rd byte of an IETF RFC-3986 'pct-encoded'. (The 1st byte of an IETF RFC-3986 'pct-encoded' is a percent-symbol (i.e., '%'), so we don't include it in the parameters.)
For example, this:
b, err := rfc3986.DecodePctEncoded('2', 'F')
Would return:
'/'
func HasPrefixPctEncoded ¶
HasPrefixPctEncoded returns true if what is at the beginning of the string is 'pct-encoded' as defined by IETF RFC-3986.
For example, any of these would return 'true':
"%2Fdir" "%7Ejoeblow"
And, for example, any of these would return 'false':
"Hello world!" "dir%2F" "joeblow%40example.com"
'pct-encoded' is defined by IETF RFC-3986 as follows:
pct-encoded = "%" HEXDIG HEXDIG
Where 'HEXDIG' is defined in IETF RFC-2234 as:
HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
DIGIT = %x30-39
; 0-9
func IsAlphaNum ¶
func IsGenDelim ¶
IsGenDelim returns true if the value of 'r' matches 'sub-delims' as defined in IETF RFC-3986:
gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
func IsPctEncodedPrefix ¶
IsPctEncodedPrefix return 'true' if the rune is the 'pct-encoded' prefix character (i.e., if it is '%'), and returns 'false' otherwise.
Note, to determine if a string begins with a 'pct-encoded' instead use HasPrefixPctEncoded.
func IsReserved ¶
IsReserved returns true if value of 'r' matches 'reserved' as defined in IETF RFC-3986:
reserved = gen-delims / sub-delims
gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
func IsSubDelim ¶
IsSubDelim returns true if the value of 'r' matches 'sub-delims' as defined in IETF RFC-3986:
sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
func IsUnreserved ¶
IsUnreserved returns true if the value of 'r' matches 'unreserved' as defined in IETF RFC-3986:
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
func PeekPrefixFragment ¶
PeekPrefixFragment 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).
PeekPrefixFragment 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 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 PeekPrefixScheme ¶
PeekPrefixScheme peeks and returns the 'scheme' as defined by IETF RFC-3986:
scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) ALPHA = %41-%5A / %61-%7A DIGIT = %30-%39
func ReadScheme ¶
ReadScheme reads and return the 'scheme' as defined by IETF RFC-3986:
scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) ALPHA = %41-%5A / %61-%7A DIGIT = %30-%39
Although ReadScheme reads the colon (":") it does not return it as part of the scheme.
func ValidateScheme ¶
Types ¶
This section is empty.