roadrunner_uri (roadrunner v0.1.0)

View Source

URI percent-encoding helpers (RFC 3986 §2.1).

Pure binary in / binary out. Used by roadrunner_qs and the eventual router.

Summary

Functions

Decode a percent-encoded binary.

Percent-encode a binary per RFC 3986.

Functions

percent_decode(Bin)

-spec percent_decode(binary()) -> {ok, binary()} | {error, badarg}.

Decode a percent-encoded binary.

Replaces every %HH triple with the byte it encodes. Hex digits are case-insensitive. Returns {error, badarg} if % is not followed by exactly two hex digits — including a lone % at end of input.

percent_encode(Bin)

-spec percent_encode(binary()) -> binary().

Percent-encode a binary per RFC 3986.

Bytes in the unreserved set (ALPHA / DIGIT / - / . / _ / ~) pass through unchanged; every other byte is replaced by %HH with uppercase hex digits (per RFC 3986 §2.1 normalization recommendation).