Skip to content

Commit 2fa0348

Browse files
committed
Fix enc() to use percent-encoding instead of form-encoding for path segments
URLEncoder.encode produces + for spaces (application/x-www-form-urlencoded). Path segments require %20 per RFC 3986. Replace + with %20 after encoding.
1 parent c258501 commit 2fa0348

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/main/java/voiceit/java/VoiceIt3.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ public VoiceIt3(String apiKey, String apiToken, String customBaseURL, SSLContext
7373
// or '?' cannot change the endpoint or inject query parameters.
7474
private static String enc(String s) {
7575
try {
76-
return URLEncoder.encode(s, "UTF-8");
76+
// URLEncoder produces application/x-www-form-urlencoded (spaces → +).
77+
// Path segments need percent-encoding (spaces → %20), so fix up after.
78+
return URLEncoder.encode(s, "UTF-8").replace("+", "%20");
7779
} catch (java.io.UnsupportedEncodingException e) {
7880
throw new RuntimeException("UTF-8 not supported", e);
7981
}

0 commit comments

Comments
 (0)