Merge branch 'develop' into Login

This commit is contained in:
Stefan Schueller 2018-12-02 15:12:17 +01:00
commit d65243945f

View File

@ -3,6 +3,7 @@ package net.schueller.peertube.helper;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.webkit.URLUtil;
import net.schueller.peertube.R;
@ -10,7 +11,13 @@ public class APIUrlHelper{
public static String getUrl(Context context) {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
return sharedPref.getString("pref_api_base", context.getResources().getString(R.string.pref_default_api_base_url));
// validate URL is valid
String URL = sharedPref.getString("pref_api_base", context.getResources().getString(R.string.pref_default_api_base_url));
if (!URLUtil.isValidUrl(URL)) {
return "http://invalid";
}
return URL;
}
public static String getUrlWithVersion(Context context) {