Painless support for URI encoding


I wasn't sure where to post this, since it's specific to the painless language, but given that I'm using thing from Alerting I figured this was the appropriate category.

I'm trying to URLencode a string, which should be possible with the following code:


However, Painless does not seem to include the method .getBytes() on java.lang.String, which makes the encodeToString a bit useless. Is there any way to convert a string to a byte-array (the parameter type of encodeToString) in Painless.


That does not produce a URL encoded string.
Base64.getUrlEncoder() returns a URL-safe base64 encoder - that is, it is a Base64 encoder that only uses characters that are "url-safe". Specifically it uses _ and - for the 2 non-alphnumeric characters and doesn't include newlines.
That is not a URL encoder.

Unfortunately, I don't believe painless includes support for URL encoding.

Hi Tim,

Thanks, I appreciate the clarification.


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.