import org.jetbrains.annotations.NotNull;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Objects;
profileNameLayout.setError(getResources().getText(R.string.err_profile_name_empty));
}
- val = String.valueOf(url.getText());
- if (val.trim().isEmpty()) {
+ val = String.valueOf(url.getText()).trim();
+ if (val.isEmpty()) {
valid = false;
urlLayout.setError(getResources().getText(R.string.err_profile_url_empty));
}
+ try {
+ URL url = new URL(val);
+ String host = url.getHost();
+ if (host == null || host.isEmpty()) throw new MalformedURLException("Missing host");
+ }
+ catch (MalformedURLException e) {
+ valid = false;
+ urlLayout.setError(getResources().getText(R.string.err_invalid_url));
+ }
if (useAuthentication.isChecked()) {
val = String.valueOf(userName.getText());
if (val.trim().isEmpty()) {
<string name="remove_profile_dialog_message">Потвърдете окончателното премахване на профила</string>
<string name="Remove">Премахване</string>
<string name="text_loading">Зареждане…</string>
+ <string name="err_invalid_url">Грешен или непълен адрес</string>
</resources>
<string name="remove_profile_dialog_message">Permanently remove this profile?</string>
<string name="Remove">Remove</string>
<string name="text_loading">Loading…</string>
+ <string name="err_invalid_url">Invalid URL</string>
</resources>