Remove exсessive check

This commit is contained in:
cepprice 2021-01-04 02:36:07 +05:00
parent 6415db6230
commit ef39c2f79b

View file

@ -61,7 +61,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.view.ContextThemeWrapper; import androidx.appcompat.view.ContextThemeWrapper;
@ -897,14 +896,6 @@ public class AmenityMenuBuilder extends MenuBuilder {
} }
private String getSocialMediaUrl(String key, String value) { private String getSocialMediaUrl(String key, String value) {
// Regex for url without protocol, with at least 2 valid domains, slash and at least one
// char after it (e.g. a-c.com/a)
String urlMask = "[a-zA-Z0-9]+[-]*[a-zA-Z0-9]+(\\.[a-zA-Z0-9]+[-]*[a-zA-Z0-9]+)+\\/.+";
if (Pattern.matches(urlMask, value)) {
return "https://" + value;
}
// Remove leading and closing slashes // Remove leading and closing slashes
StringBuilder sb = new StringBuilder(value.trim()); StringBuilder sb = new StringBuilder(value.trim());
if (sb.charAt(0) == '/') { if (sb.charAt(0) == '/') {
@ -916,8 +907,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
} }
// It cannot be username // It cannot be username
if (sb.indexOf("/") != -1 || sb.indexOf(" ") != -1) { if (sb.indexOf("/") != -1) {
return null; return "https://" + value;
} }
Map<String, String> urls = new HashMap<>(7); Map<String, String> urls = new HashMap<>(7);