expandTemplateURIVariable

Expands a variable template part of a URI template as defined in RFC 6570.

Parameters

templateString string

The template variable definition without surrounding braces.

resolveVariable VariableCallback

Callback delegate to resolve a variable name (parameter) to the variable value. (return value) May be called more than once per variable name. See VariableCallback. Values are percent encoded by this function and must not be encoded by the callback function.

Note that all values returned by this function MUST be formed prior to template expansion in order to comply with RFC 6570. Therefore to ensure compatibility a given variable name must always evaluate to the same value every time.

strict bool

Validate entire string strictly according to RFC 6570. Does NOT perform unicode code-point validation. Performs character-by-character checks for exact grammar checks.

index size_t

Byte index to offset malformed URI format exceptions.

Return Value

Type: string

the resolved variable value (properly URI encoded)

Throws

TemplateURIFormatException on attempted use of a reserved operator, invalid variable specifications or strict issues.

Examples

assert(expandTemplateURIVariable(`?since,all,participating`,
		delegate(string k) @safe => URIVariable.init) == "");

assert(expandTemplateURIVariable(`?since,all,participating`, null) == "");

assert(expandTemplateURIVariable(`?since,all,participating`, ["all": "1"]) == "?all=1");

assert(expandTemplateURIVariable(`?since,all,participating`, [
			"all": URIVariable("1"),
			"participating": URIVariable("1")
		]) == "?all=1&participating=1");

Meta