roadrunner_qs (roadrunner v0.1.0)

View Source

application/x-www-form-urlencoded query string codec.

Pairs are separated by &; key and value within each pair are separated by =. + decodes to space (legacy form-encoding rule), followed by RFC 3986 percent-decoding via roadrunner_uri. Bare keys with no = are flags — their value is the atom true.

Lenient on malformed input (cowboy parity): empty pair entries (&&, leading or trailing &) are skipped, and percent sequences that fail to decode pass through as raw bytes.

Summary

Functions

Encode a list of {Key, Value} pairs as a query string.

Parse a query string into an ordered list of {Key, Value} pairs.

Functions

encode(Pairs)

-spec encode([{binary(), binary() | true}]) -> binary().

Encode a list of {Key, Value} pairs as a query string.

Value may be true (bare flag, no =) or a binary. Spaces are encoded as + (form-encoding convention); other non-unreserved bytes become %HH triples — including a literal +, which becomes %2B so it round-trips through parse/1.

parse/1

-spec parse(binary()) -> [{binary(), binary() | true}].

Parse a query string into an ordered list of {Key, Value} pairs.

Value is true for bare flags, otherwise a binary (possibly empty).