I wish to construct a URL with properly escaped characters, with an optional query on the end. I could do this with string operations and URL::addEscapeChars(), but I'm already passing URL objects around and I thought URL::toString() would do this for me. Here's the problem:
If a URL object is constructed from a string, the URL constructor removes all escape chars after the query (?), but doesn't do anything with the main URL path (ie. everything before the query).
Similarly, when a string is obtained using URL::toString(), the function adds escape chars to everything after the query but returns the main URL path as-is ie. without adding escape chars.
Since the URL path should be escaped too, my expectation is that it should get the same treatment as the query parameters. What am I missing?