Merge branch 'trailing_url_slash' of https://github.com/klonfish/Conversations into klonfish-trailing_url_slash
This commit is contained in:
commit
17db77ed5d
|
@ -104,7 +104,42 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
|
||||||
return "http://" + removeTrailingBracket(url);
|
return "http://" + removeTrailingBracket(url);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private static final Linkify.MatchFilter WEBURL_MATCH_FILTER = (cs, start, end) -> start < 1 || (cs.charAt(start - 1) != '@' && cs.charAt(start - 1) != '.' && !cs.subSequence(Math.max(0, start - 3), start).equals("://"));
|
|
||||||
|
private static String removeTrailingBracket(final String url) {
|
||||||
|
int numOpenBrackets = 0;
|
||||||
|
for (char c : url.toCharArray()) {
|
||||||
|
if (c == '(') {
|
||||||
|
++numOpenBrackets;
|
||||||
|
} else if (c == ')') {
|
||||||
|
--numOpenBrackets;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (numOpenBrackets != 0 && url.charAt(url.length() - 1) == ')') {
|
||||||
|
return url.substring(0, url.length() - 1);
|
||||||
|
} else {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Linkify.MatchFilter WEBURL_MATCH_FILTER = (cs, start, end) -> {
|
||||||
|
if (start > 0) {
|
||||||
|
if (cs.charAt(start - 1) == '@' || cs.charAt(start - 1) == '.'
|
||||||
|
|| cs.subSequence(Math.max(0, start - 3), start).equals("://")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end < cs.length()) {
|
||||||
|
// Reject strings that were probably matched only because they contain a dot followed by
|
||||||
|
// by some known TLD (see also comment for WORD_BOUNDARY in Patterns.java)
|
||||||
|
if (Character.isAlphabetic(cs.charAt(end-1)) && Character.isAlphabetic(cs.charAt(end))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
private static final Linkify.MatchFilter XMPPURI_MATCH_FILTER = (s, start, end) -> {
|
private static final Linkify.MatchFilter XMPPURI_MATCH_FILTER = (s, start, end) -> {
|
||||||
XmppUri uri = new XmppUri(s.subSequence(start, end).toString());
|
XmppUri uri = new XmppUri(s.subSequence(start, end).toString());
|
||||||
return uri.isJidValid();
|
return uri.isJidValid();
|
||||||
|
@ -127,21 +162,6 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
|
||||||
updatePreferences();
|
updatePreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String removeTrailingBracket(final String url) {
|
|
||||||
int numOpenBrackets = 0;
|
|
||||||
for (char c : url.toCharArray()) {
|
|
||||||
if (c == '(') {
|
|
||||||
++numOpenBrackets;
|
|
||||||
} else if (c == ')') {
|
|
||||||
--numOpenBrackets;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (numOpenBrackets != 0 && url.charAt(url.length() - 1) == ')') {
|
|
||||||
return url.substring(0, url.length() - 1);
|
|
||||||
} else {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean cancelPotentialWork(Message message, ImageView imageView) {
|
public static boolean cancelPotentialWork(Message message, ImageView imageView) {
|
||||||
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
|
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
|
||||||
|
|
|
@ -353,7 +353,6 @@ public class Patterns {
|
||||||
+ "(?:" + PORT_NUMBER + ")?"
|
+ "(?:" + PORT_NUMBER + ")?"
|
||||||
+ ")"
|
+ ")"
|
||||||
+ "(?:" + PATH_AND_QUERY + ")?"
|
+ "(?:" + PATH_AND_QUERY + ")?"
|
||||||
+ WORD_BOUNDARY
|
|
||||||
+ ")";
|
+ ")";
|
||||||
/**
|
/**
|
||||||
* Regular expression to match strings that start with a supported protocol. Rules for domain
|
* Regular expression to match strings that start with a supported protocol. Rules for domain
|
||||||
|
@ -367,7 +366,6 @@ public class Patterns {
|
||||||
+ "(?:" + PORT_NUMBER + ")?"
|
+ "(?:" + PORT_NUMBER + ")?"
|
||||||
+ ")"
|
+ ")"
|
||||||
+ "(?:" + PATH_AND_QUERY + ")?"
|
+ "(?:" + PATH_AND_QUERY + ")?"
|
||||||
+ WORD_BOUNDARY
|
|
||||||
+ ")";
|
+ ")";
|
||||||
/**
|
/**
|
||||||
* Regular expression pattern to match IRIs. If a string starts with http(s):// the expression
|
* Regular expression pattern to match IRIs. If a string starts with http(s):// the expression
|
||||||
|
|
Loading…
Reference in a new issue