URI encode pathname parts?
OliverJAsh opened this issue · comments
Oliver Joseph Ash commented
Should this library handle URI encoding of the pathname "parts" when formatting a route, or should that be handled by the user?
Currently, query params are URI encoded, but pathname parts are not:
E.g.
const searchQueryQueryParam = query(t.interface({ q: t.string })).then(end);
const searchQuery = lit("search")
.then(str("query"))
.then(end);
const formatRoute = <A extends object>(match: Match<A>) => (route: A): string =>
match.formatter.run(RouteBase.empty, route).toString();
console.log(formatRoute(searchQueryQueryParam)({ q: "foo bar baz" })); // => "/?q=foo%20bar%20baz"
console.log(formatRoute(searchQuery)({ query: "foo bar baz" })); // => "/search/foo bar baz"
Giulio Canti commented
Thanks @OliverJAsh, looks like a bug