Fix bug with inserting malformed image links

This commit is contained in:
Balazs Toldi 2023-08-18 15:39:56 +02:00
parent 0e31e40ef1
commit 495a1d025f
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58

View File

@ -49,7 +49,11 @@ public class UploadImageUtils {
if (uploadMediaResponse.isSuccessful()) {
JSONObject responseObject = new JSONObject(uploadMediaResponse.body());
String fileName = responseObject.getJSONArray("files").getJSONObject(0).getString("file");
return mRetrofit.getBaseURL() + "/pictrs/image/" + fileName;
String baseURL = mRetrofit.getBaseURL();
if (baseURL.endsWith("/")) {
baseURL = baseURL.substring(0, baseURL.length() - 1);
}
return baseURL + "/pictrs/image/" + fileName;
} else {
return "Error: " + uploadMediaResponse.code();
}