url-encode

Percent-encoding (RFC 3986) replaces characters that are not unreserved — not in A–Z a–z 0–9 - _ . ~ — with a %XX hex escape. Spaces become %20. Reserved characters like & = ? / are also encoded when they appear in a query value rather than as delimiters.

The round-trip property (decode (encode s)) = s holds for any string. The pure transform lives in wal-sh.tools.url-encode.core (host-neutral .cljc, tested on the JVM with test.check). The browser adapter is wal-sh.tools.url-encode.browser, which delegates to js/encodeURIComponent / js/decodeURIComponent in ClojureScript and java.net.URLEncoder / java.net.URLDecoder on the JVM. Build: gmake tools-cljs; debug in isolation: gmake dev-tool TOOL=url-encode.