Fix regex

This commit is contained in:
Nathan Mascitelli 2019-03-02 12:12:26 -05:00
parent 6f69b4b140
commit 7e3ccd97da
2 changed files with 9 additions and 3 deletions

View File

@ -151,9 +151,15 @@ public class TimelineTest extends InstrumentationTestCase {
} }
public void testProcessShownotesAndInvalidTimecode() throws Exception { public void testProcessShownotesAndInvalidTimecode() throws Exception {
final String timeStr = "2:1"; final String[] timeStrs = new String[] {"2:1", "0:0", "000", "00", "00:000"};
Playable p = newTestPlayable(null, "<p> Some test text with a timecode <" + timeStr + "> here.</p>", Integer.MAX_VALUE); StringBuilder shownotes = new StringBuilder("<p> Some test text with timecodes ");
for (String timeStr : timeStrs) {
shownotes.append(timeStr).append(" ");
}
shownotes.append("here.</p>");
Playable p = newTestPlayable(null, shownotes.toString(), Integer.MAX_VALUE);
Timeline t = new Timeline(context, p); Timeline t = new Timeline(context, p);
String res = t.processShownotes(true); String res = t.processShownotes(true);
checkLinkCorrect(res, new long[0], new String[0]); checkLinkCorrect(res, new long[0], new String[0]);

View File

@ -70,7 +70,7 @@ public class Timeline {
private static final Pattern TIMECODE_LINK_REGEX = Pattern.compile("antennapod://timecode/((\\d+))"); private static final Pattern TIMECODE_LINK_REGEX = Pattern.compile("antennapod://timecode/((\\d+))");
private static final String TIMECODE_LINK = "<a class=\"timecode\" href=\"antennapod://timecode/%d\">%s</a>"; private static final String TIMECODE_LINK = "<a class=\"timecode\" href=\"antennapod://timecode/%d\">%s</a>";
private static final Pattern TIMECODE_REGEX = Pattern.compile("\\b(?:(?:(\\d*):)?([0-5]?\\d):)?([0-5][0-9]?\\d)\\b"); private static final Pattern TIMECODE_REGEX = Pattern.compile("\\b(?:(?:(\\d*):)?([0-5]?\\d))?:([0-5]\\d)\\b");
private static final Pattern LINE_BREAK_REGEX = Pattern.compile("<br */?>"); private static final Pattern LINE_BREAK_REGEX = Pattern.compile("<br */?>");