Permalink
Browse files

Add test cases where hashtag/@mention and URL are overlapped.

  • Loading branch information...
1 parent 07375bf commit f67226d0a41863d64db329e2e7ef77192c18d079 @keitaf keitaf committed Oct 14, 2011
Showing with 24 additions and 0 deletions.
  1. +12 −0 autolink.yml
  2. +12 −0 extract.yml
View
12 autolink.yml
@@ -648,3 +648,15 @@ tests:
- description: "Does not allow an XSS after an @"
text: "See: http://x.xx.com/@\"style=\"color:pink\"onmouseover=alert(1)//"
expected: "See: <a href=\"http://x.xx.com/\">http://x.xx.com/</a>@\"style=\"color:pink\"onmouseover=alert(1)//"
+
+ - description: "DO NOT autolink URLs if preceded by # or @"
+ text: "#http://twitter.com @http://twitter.com"
+ expected: "#http://twitter.com @http://twitter.com"
+
+ - description: "Autolink hashtag if followed by . and TLD"
+ text: "#twitter.com #twitter.co.jp"
+ expected: "<a href=\"http://twitter.com/search?q=%23twitter\" title=\"#twitter\" class=\"tweet-url hashtag\">#twitter</a>.com <a href=\"http://twitter.com/search?q=%23twitter\" title=\"#twitter\" class=\"tweet-url hashtag\">#twitter</a>.co.jp"
+
+ - description: "Autolink @mention if followed by . and TLD"
+ text: "@twitter.com @twitter.co.jp"
+ expected: "@<a class=\"tweet-url username\" href=\"http://twitter.com/twitter\">twitter</a>.com @<a class=\"tweet-url username\" href=\"http://twitter.com/twitter\">twitter</a>.co.jp"
View
12 extract.yml
@@ -41,6 +41,10 @@ tests:
text: "@username email me @test@example.com"
expected: ["username"]
+ - description: "DO NOT extract 'http' in '@http://' as username"
+ text: "@http://twitter.com"
+ expected: []
+
mentions_with_indices:
- description: "Extract a mention at the start"
text: "@username yo!"
@@ -148,6 +152,10 @@ tests:
text: "@@username mention, not a reply"
expected:
+ - description: "DO NOT Extract reply when followed by URL"
+ text: "@http://twitter.com"
+ expected:
+
urls:
- description: "Extract a lone URL"
text: "http://example.com"
@@ -540,6 +548,10 @@ tests:
text: ":#hashtag ;#hashtag ,#hashtag .#hashtag !#hashtag ?#hashtag"
expected: ["hashtag", "hashtag", "hashtag", "hashtag", "hashtag", "hashtag"]
+ - description: "DO NOT extract hashtag when # is followed by URL"
+ text: "#http://twitter.com #https://twitter.com"
+ expected: []
+
hashtags_with_indices:
- description: "Extract a hastag at the start"
text: "#hashtag here"

0 comments on commit f67226d

Please sign in to comment.