Fix bug with advancing the position when linkifying failed
This commit is contained in:
parent
0f9bc4867a
commit
98974a7699
2 changed files with 10 additions and 1 deletions
|
@ -51,7 +51,7 @@ public class UriLinkifier {
|
|||
boolean uriWasNotLinkified = newPos <= startPos;
|
||||
if (uriWasNotLinkified) {
|
||||
outputBuffer.append(text.charAt(startPos));
|
||||
currentPos++;
|
||||
currentPos = startPos + 1;
|
||||
} else {
|
||||
currentPos = (newPos > currentPos) ? newPos : currentPos + 1;
|
||||
}
|
||||
|
|
|
@ -115,4 +115,13 @@ public class UriLinkifierTest {
|
|||
|
||||
assertEquals("myhttp: <a href=\"http://example.org\">http://example.org</a>", outputBuffer.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void schemaMatchWithInvalidUriInMiddleOfTextFollowedVyValidUri() throws Exception {
|
||||
String text = "prefix http:42 http://example.org";
|
||||
|
||||
UriLinkifier.linkifyText(text, outputBuffer);
|
||||
|
||||
assertEquals("prefix http:42 <a href=\"http://example.org\">http://example.org</a>", outputBuffer.toString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue