refactor(StatusDisplayItem/quote): use regex to find last URL
This commit is contained in:
parent
ff90e21e86
commit
a67c8b36b1
|
@ -87,7 +87,7 @@ public abstract class StatusDisplayItem{
|
||||||
|
|
||||||
|
|
||||||
private final static Pattern QUOTE_MENTION_PATTERN=Pattern.compile("(?:<p>)?\\s?(?:RE:\\s?)?<a href=\"https:\\/\\/[^\"]+\"[^>]*><span class=\"invisible\">https:\\/\\/<\\/span><span class=\"ellipsis\">[^<]+<\\/span><span class=\"invisible\">[^<]+<\\/span><\\/a>(?:<\\/p>)?$");
|
private final static Pattern QUOTE_MENTION_PATTERN=Pattern.compile("(?:<p>)?\\s?(?:RE:\\s?)?<a href=\"https:\\/\\/[^\"]+\"[^>]*><span class=\"invisible\">https:\\/\\/<\\/span><span class=\"ellipsis\">[^<]+<\\/span><span class=\"invisible\">[^<]+<\\/span><\\/a>(?:<\\/p>)?$");
|
||||||
private final static Pattern QUOTE_PATTERN=Pattern.compile("[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)");
|
private final static Pattern QUOTE_PATTERN=Pattern.compile("[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)$");
|
||||||
|
|
||||||
public void setAncestryInfo(
|
public void setAncestryInfo(
|
||||||
boolean hasDescendantNeighbor,
|
boolean hasDescendantNeighbor,
|
||||||
|
@ -422,11 +422,9 @@ public abstract class StatusDisplayItem{
|
||||||
private static void tryAddNonOfficialQuote(Status status, BaseStatusListFragment fragment, String accountID) {
|
private static void tryAddNonOfficialQuote(Status status, BaseStatusListFragment fragment, String accountID) {
|
||||||
Matcher matcher=QUOTE_PATTERN.matcher(status.getStrippedText());
|
Matcher matcher=QUOTE_PATTERN.matcher(status.getStrippedText());
|
||||||
|
|
||||||
String quoteURL=null;
|
if(!matcher.find())
|
||||||
while (matcher.find()) {
|
return;
|
||||||
quoteURL=matcher.group(0);
|
String quoteURL="https://"+matcher.group();
|
||||||
}
|
|
||||||
quoteURL="https://"+quoteURL;
|
|
||||||
|
|
||||||
if (UiUtils.looksLikeFediverseUrl(quoteURL)) {
|
if (UiUtils.looksLikeFediverseUrl(quoteURL)) {
|
||||||
new GetSearchResults(quoteURL, GetSearchResults.Type.STATUSES, true, null, 0, 0).setCallback(new Callback<>(){
|
new GetSearchResults(quoteURL, GetSearchResults.Type.STATUSES, true, null, 0, 0).setCallback(new Callback<>(){
|
||||||
|
@ -444,7 +442,7 @@ public abstract class StatusDisplayItem{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(ErrorResponse error){
|
public void onError(ErrorResponse error){
|
||||||
Log.w("StatusDisplayItem", "onError: failed to find quote status" +error);
|
Log.w("StatusDisplayItem", "onError: failed to find quote status with URL: " + quoteURL + " " + error);
|
||||||
}
|
}
|
||||||
}).exec(accountID);
|
}).exec(accountID);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue