From 0a182209982c8c5ada1869574634ee0cad48d8a8 Mon Sep 17 00:00:00 2001 From: Kurian Vithayathil Date: Wed, 21 Sep 2022 01:56:26 -0400 Subject: Fix 'Suggested Title' bug (#1120) - Fixed issue where a post's suggested titles would fail to generate Co-authored-by: Kurian Vithayathil --- .../infinityforreddit/activities/PostLinkActivity.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java index 3db21105..562b55db 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java @@ -9,6 +9,7 @@ import android.os.Handler; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.webkit.URLUtil; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; @@ -351,10 +352,10 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr suggestTitleButton.setOnClickListener(view -> { Toast.makeText(this, R.string.please_wait, Toast.LENGTH_SHORT).show(); String url = linkEditText.getText().toString().trim(); - if (!url.startsWith("https://") || !url.startsWith("http://")) { + if (!URLUtil.isHttpsUrl(url) && !URLUtil.isHttpUrl(url)) { url = "https://" + url; } - new Retrofit.Builder() + mRetrofit.newBuilder() .baseUrl("http://localhost/") .addConverterFactory(ScalarsConverterFactory.create()) .build().create(TitleSuggestion.class).getHtml(url).enqueue(new Callback() { -- cgit v1.2.3