Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

243 lines (183 sloc) 11.711 kb
tests:
usernames:
- description: "Autolink trailing username"
text: "text @username"
expected: "text @<a class=\"tweet-url username\" href=\"http://twitter.com/username\">username</a>"
- description: "Autolink username at the beginning"
text: "@username text"
expected: "@<a class=\"tweet-url username\" href=\"http://twitter.com/username\">username</a> text"
- description: "DO NOT Autolink username preceded by a letter"
text: "meet@the beach"
expected: "meet@the beach"
- description: "Autolink username preceded by puctuation"
text: "great.@username"
expected: "great.@<a class=\"tweet-url username\" href=\"http://twitter.com/username\">username</a>"
- description: "Autolink username followed by puctuation"
text: "@username&^$%^"
expected: "@<a class=\"tweet-url username\" href=\"http://twitter.com/username\">username</a>&^$%^"
- description: "Autolink username followed by Japanese"
text: "@usernameの"
expected: "@<a class=\"tweet-url username\" href=\"http://twitter.com/username\">username</a>の"
- description: "Autolink username preceded by Japanese"
text: "あ@username"
expected: "あ@<a class=\"tweet-url username\" href=\"http://twitter.com/username\">username</a>"
- description: "Autolink username surrounded by Japanese"
text: "あ@usernameの"
expected: "あ@<a class=\"tweet-url username\" href=\"http://twitter.com/username\">username</a>の"
- description: "Autolink username with full-width at sign (U+FF20)"
text: "@username"
expected: "@<a class=\"tweet-url username\" href=\"http://twitter.com/username\">username</a>"
- description: "DO NOT Autolink username over 20 characters"
text: "@username9012345678901"
expected: "@<a class=\"tweet-url username\" href=\"http://twitter.com/username901234567890\">username901234567890</a>1"
lists:
- description: "Autolink list preceded by a space"
text: "text @username/list"
expected: "text @<a class=\"tweet-url list-slug\" href=\"http://twitter.com/username/list\">username/list</a>"
- description: "DO NOT Autolink list when space follows slash"
text: "text @username/ list"
expected: "text @<a class=\"tweet-url username\" href=\"http://twitter.com/username\">username</a>/ list"
- description: "DO NOT Autolink list with empty username"
text: "text @/list"
expected: "text @/list"
- description: "Autolink list at the beginning"
text: "@username/list"
expected: "@<a class=\"tweet-url list-slug\" href=\"http://twitter.com/username/list\">username/list</a>"
- description: "DO NOT Autolink list preceded by letter"
text: "meet@the/beach"
expected: "meet@the/beach"
- description: "Autolink list preceded by puctuation"
text: "great.@username/list"
expected: "great.@<a class=\"tweet-url list-slug\" href=\"http://twitter.com/username/list\">username/list</a>"
- description: "Autolink list followed by puctuation"
text: "@username/list&^$%^"
expected: "@<a class=\"tweet-url list-slug\" href=\"http://twitter.com/username/list\">username/list</a>&^$%^"
- description: "Autolink list name over 80 characters (truncated to 80)"
text: "@username/list5678901234567890123456789012345678901234567890123456789012345678901234567890A"
expected: "@<a class=\"tweet-url list-slug\" href=\"http://twitter.com/username/list5678901234567890123456789012345678901234567890123456789012345678901234567890\">username/list5678901234567890123456789012345678901234567890123456789012345678901234567890</a>A"
hashtags:
- description: "Autolink trailing hashtag"
text: "text #hashtag"
expected: "text <a href=\"http://twitter.com/search?q=%23hashtag\" title=\"#hashtag\" class=\"tweet-url hashtag\">#hashtag</a>"
- description: "Autolink alphanumeric hashtag (letter-number-letter)"
text: "text #hash0tag"
expected: "text <a href=\"http://twitter.com/search?q=%23hash0tag\" title=\"#hash0tag\" class=\"tweet-url hashtag\">#hash0tag</a>"
- description: "Autolink alphanumeric hashtag (number-letter)"
text: "text #1tag"
expected: "text <a href=\"http://twitter.com/search?q=%231tag\" title=\"#1tag\" class=\"tweet-url hashtag\">#1tag</a>"
- description: "Autolink hashtag with underscore"
text: "text #hash_tag"
expected: "text <a href=\"http://twitter.com/search?q=%23hash_tag\" title=\"#hash_tag\" class=\"tweet-url hashtag\">#hash_tag</a>"
- description: "DO NOT Autolink all-numeric hashtags"
text: "text #1234"
expected: "text #1234"
- description: "DO NOT Autolink hashtag preceded by a letter"
text: "text#hashtag"
expected: "text#hashtag"
- description: "Autolink multiple hashtags"
text: "text #hashtag1 #hashtag2"
expected: "text <a href=\"http://twitter.com/search?q=%23hashtag1\" title=\"#hashtag1\" class=\"tweet-url hashtag\">#hashtag1</a> <a href=\"http://twitter.com/search?q=%23hashtag2\" title=\"#hashtag2\" class=\"tweet-url hashtag\">#hashtag2</a>"
- description: "Autolink hashtag preceded by a period"
text: "text.#hashtag"
expected: "text.<a href=\"http://twitter.com/search?q=%23hashtag\" title=\"#hashtag\" class=\"tweet-url hashtag\">#hashtag</a>"
- description: "DO NOT Autolink hashtag preceded by &"
text: "&#nbsp;"
expected: "&#nbsp;"
- description: "Autolink hashtag followed by ! (! not included)"
text: "text #hashtag!"
expected: "text <a href=\"http://twitter.com/search?q=%23hashtag\" title=\"#hashtag\" class=\"tweet-url hashtag\">#hashtag</a>!"
- description: "Autolink hashtag followed by Japanese"
text: "text #hashtagの"
expected: "text <a href=\"http://twitter.com/search?q=%23hashtag\" title=\"#hashtag\" class=\"tweet-url hashtag\">#hashtag</a>の"
- description: "Autolink hashtag preceded by full-width space (U+3000)"
text: "text #hashtag"
expected: "text <a href=\"http://twitter.com/search?q=%23hashtag\" title=\"#hashtag\" class=\"tweet-url hashtag\">#hashtag</a>"
- description: "Autolink hashtag followed by full-width space (U+3000)"
text: "#hashtag text"
expected: "<a href=\"http://twitter.com/search?q=%23hashtag\" title=\"#hashtag\" class=\"tweet-url hashtag\">#hashtag</a> text"
- description: "Autolink hashtag with full-width hash (U+FF03)"
text: "#hashtag"
expected: "<a href=\"http://twitter.com/search?q=%23hashtag\" title=\"#hashtag\" class=\"tweet-url hashtag\">#hashtag</a>"
urls:
- description: "Autolink trailing url"
text: "text http://example.com"
expected: "text <a href=\"http://example.com\">http://example.com</a>"
- description: "Autolink url in mid-text"
text: "text http://example.com more text"
expected: "text <a href=\"http://example.com\">http://example.com</a> more text"
- description: "Autolink url in Japanese text"
text: "いまなにしてるhttp://example.comいまなにしてる"
expected: "いまなにしてる<a href=\"http://example.com\">http://example.com</a>いまなにしてる"
- description: "Autolink url surrounded by parentheses"
text: "text (http://example.com)"
expected: "text (<a href=\"http://example.com\">http://example.com</a>)"
- description: "Autolink url containing unicode characters"
text: "I enjoy Macintosh Brand computers: http://✪df.ws/ejp"
expected: "I enjoy Macintosh Brand computers: <a href=\"http://✪df.ws/ejp\">http://✪df.ws/ejp</a>"
- description: "Autolink url preceded by :"
text: "text:http://example.com"
expected: "text:<a href=\"http://example.com\">http://example.com</a>"
- description: "Autolink url followed by ? (without it)"
text: "text http://example.com?"
expected: "text <a href=\"http://example.com\">http://example.com</a>?"
- description: "Autolink url followed by ! (without it)"
text: "text http://example.com!"
expected: "text <a href=\"http://example.com\">http://example.com</a>!"
- description: "Autolink url followed by , (without it)"
text: "text http://example.com,"
expected: "text <a href=\"http://example.com\">http://example.com</a>,"
- description: "Autolink url followed by . (without it)"
text: "text http://example.com."
expected: "text <a href=\"http://example.com\">http://example.com</a>."
- description: "Autolink url followed by : (without it)"
text: "text http://example.com:"
expected: "text <a href=\"http://example.com\">http://example.com</a>:"
- description: "Autolink url followed by ; (without it)"
text: "text http://example.com;"
expected: "text <a href=\"http://example.com\">http://example.com</a>;"
- description: "Autolink url followed by ] (without it)"
text: "text http://example.com]"
expected: "text <a href=\"http://example.com\">http://example.com</a>]"
- description: "Autolink url followed by ) (without it)"
text: "text http://example.com)"
expected: "text <a href=\"http://example.com\">http://example.com</a>)"
- description: "Autolink url followed by } (without it)"
text: "text http://example.com}"
expected: "text <a href=\"http://example.com\">http://example.com</a>}"
- description: "Autolink url followed by = (without it)"
text: "text http://example.com="
expected: "text <a href=\"http://example.com\">http://example.com</a>="
- description: "Autolink url followed by ' (without it)"
text: "text http://example.com'"
expected: "text <a href=\"http://example.com\">http://example.com</a>'"
- description: "DO NOT Autolink url preceded by '"
text: "text 'http://example.com"
expected: "text 'http://example.com"
- description: "DO NOT Autolink url preceded by /"
text: "text /http://example.com"
expected: "text /http://example.com"
- description: "DO NOT Autolink url preceded by !"
text: "text !http://example.com"
expected: "text !http://example.com"
- description: "DO NOT Autolink url preceded by ="
text: "text =http://example.com"
expected: "text =http://example.com"
- description: "Autolink url embedded in link tag"
text: "<link rel='true'>http://example.com</link>"
expected: "<link rel='true'><a href=\"http://example.com\">http://example.com</a></link>"
- description: "Autolink multiple urls"
text: "http://example.com https://sslexample.com http://sub.example.com"
expected: "<a href=\"http://example.com\">http://example.com</a> <a href=\"https://sslexample.com\">https://sslexample.com</a> <a href=\"http://sub.example.com\">http://sub.example.com</a>"
- description: "Autolink url with long TLD"
text: "http://example.mobi/path"
expected: "<a href=\"http://example.mobi/path\">http://example.mobi/path</a>"
- description: "Autolink url without protocol (with www)"
text: "www.example.com"
expected: "<a href=\"http://www.example.com\">www.example.com</a>"
- description: "Autolink url without protocol (with WWW)"
text: "WWW.EXAMPLE.COM"
expected: "<a href=\"http://WWW.EXAMPLE.COM\">WWW.EXAMPLE.COM</a>"
all:
- description: "Autolink url does not overlap @username"
text: "Check out: http://example.com/test&@chasesechrist"
expected: "Check out: <a href=\"http://example.com/test&\">http://example.com/test&</a>@<a class=\"tweet-url username\" href=\"http://twitter.com/chasesechrist\">chasesechrist</a>"
Jump to Line
Something went wrong with that request. Please try again.