Permalink
Browse files

Add test for issue 8 (URL with $)

  • Loading branch information...
1 parent eb71d10 commit 796fb0e88da808a065ca475daf7f56b6f04b4213 Matt Sanford committed May 27, 2011
Showing with 10 additions and 2 deletions.
  1. +2 −2 src/com/twitter/Autolink.java
  2. +8 −0 tests/com/twitter/AutolinkTest.java
@@ -177,9 +177,9 @@ public String autoLinkURLs(String text) {
matcher.appendReplacement(sb,
String.format("$%s<a href=\"%s\"%s>%s</a>",
Regex.VALID_URL_GROUP_BEFORE,
- url,
+ url.replaceAll("\\$", "\\\\\\$"),
noFollow ? NO_FOLLOW_HTML_ATTRIBUTE : "",
- url
+ url.replaceAll("\\$", "\\\\\\$")
));
continue;
}
@@ -33,6 +33,14 @@ public void testBlogspotWithDash() {
assertAutolink(expected, linker.autoLinkURLs(tweet));
}
+ /** See also: https://github.com/mzsanford/twitter-text-java/issues/8 */
+ public void testURLWithDollarThatLooksLikeARegex() {
+ linker.setNoFollow(false);
+ String tweet = "Url: http://example.com/$ABC";
+ String expected = "Url: <a href=\"http://example.com/$ABC\">http://example.com/$ABC</a>";
+ assertAutolink(expected, linker.autoLinkURLs(tweet));
+ }
+
protected void assertAutolink(String expected, String linked) {
assertEquals("Autolinked text should not equal the input", expected, linked);
}

0 comments on commit 796fb0e

Please sign in to comment.