Determines if the value is already pct-encoded. @param value to check. @return {@literal true} if the value is already pct-encoded
(String value, Charset charset)
| 35 | * @return {@literal true} if the value is already pct-encoded |
| 36 | */ |
| 37 | public static boolean isEncoded(String value, Charset charset) { |
| 38 | for (byte b : value.getBytes(charset)) { |
| 39 | if (!isUnreserved((char) b) && b != '%') { |
| 40 | /* break if there are any unreserved character */ |
| 41 | return false; |
| 42 | } |
| 43 | } |
| 44 | return PCT_ENCODED_PATTERN.matcher(value).find(); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Uri Encode the value, using the default Charset. Already encoded values are skipped. |
no test coverage detected