url/url_template_utils library

URI template expansion (RFC 6570 subset) — roadmap #629.

Expands {...} expressions in a URI template against a variable map, the way API clients build request URLs from a template like https://api/users/{id}{?fields*}. Covers RFC 6570 Levels 1–3 plus the prefix ({var:3}) and explode ({list*}) modifiers:

  • simple {var} and multiple {a,b} (comma-joined, percent-encoded)
  • reserved {+var} and fragment {#var} (keep reserved chars)
  • label {.var}, path {/var}, path-style {;var}, query {?var} / {&var} (operator-specific separators and name= for the named ones)

Values may be a string, number, bool, or List; an undefined (absent or null) variable contributes nothing. Map/associative values are out of scope. Literal text outside braces is passed through unchanged.

Functions

expandUriTemplate(String template, Map<String, Object?> variables) String
Expands every {...} expression in template against variables, leaving literal text untouched.