Fix some malformed links

This commit is contained in:
Balazs Toldi 2023-08-18 21:09:28 +02:00
parent 495a1d025f
commit f61c12a30b
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
2 changed files with 6 additions and 4 deletions

View File

@ -24,7 +24,11 @@ public class RetrofitHolder {
} }
public String getBaseURL() { public String getBaseURL() {
return baseURL; String result = baseURL;
if (baseURL.endsWith("/")) {
result = baseURL.substring(0, baseURL.length() - 1);
}
return result;
} }
public RetrofitHolder(OkHttpClient okHttpClient) { public RetrofitHolder(OkHttpClient okHttpClient) {

View File

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