tests:
usernames:
- description: "Autolink trailing username"
text: "text @username"
expected: "text @username"
- description: "Autolink username at the beginning"
text: "@username text"
expected: "@username 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.@username"
- description: "Autolink username followed by puctuation"
text: "@username&^$%^"
expected: "@username&^$%^"
- description: "Autolink username followed by Japanese"
text: "@usernameの"
expected: "@usernameの"
- description: "Autolink username preceded by Japanese"
text: "あ@username"
expected: "あ@username"
- description: "Autolink username surrounded by Japanese"
text: "あ@usernameの"
expected: "あ@usernameの"
- description: "Autolink username in compressed RT"
text: "RT@username: long Tweet is loooong"
expected: "RT@username: long Tweet is loooong"
- description: "Autolink alternate RT format in middle of text"
text: "Check out RT:@username yas"
expected: "Check out RT:@username yas"
- description: "DO NOT Autolink domain of email address ending in RT like support@example.com"
text: "Email support@example.com"
expected: "Email support@example.com"
- description: "DO NOT Autolink username followed by accented latin characters"
text: "@aliceìnheiro something something"
expected: "@aliceìnheiro something something"
- description: "DO NOT Autolink username @_ in @_@"
text: "oh, snap! @_@"
expected: "oh, snap! @_@"
- description: "Autolink username with full-width at sign (U+FF20)"
text: "@username"
expected: "@username"
- description: "DO NOT Autolink username over 20 characters"
text: "@username9012345678901"
expected: "@username9012345678901"
- description: "Autolink two usernames"
text: "@foo @bar"
expected: "@foo @bar"
- description: "Autolink usernames followed by :"
text: "@foo: @bar"
expected: "@foo: @bar"
- description: "Autolink usernames that are followed by international characters"
text: "@foo îs in the house"
expected: "@foo îs in the house"
- description: "Preserve case when linking a username"
text: "@MixedCase"
expected: "@MixedCase"
lists:
- description: "Autolink list preceded by a space"
text: "text @username/list"
expected: "text @username/list"
- description: "DO NOT Autolink list when space follows slash"
text: "text @username/ list"
expected: "text @username/ 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: "@username/list"
- 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.@username/list"
- description: "Autolink list followed by puctuation"
text: "@username/list&^$%^"
expected: "@username/list&^$%^"
- description: "Autolink list name over 25 characters (truncated to 25)"
text: "@username/list567890123456789012345A"
expected: "@username/list567890123456789012345A"
- description: "Autolink list that contains an _"
text: "text @username/list_name"
expected: "text @username/list_name"
- description: "Autolink list that contains a -"
text: "text @username/list-name"
expected: "text @username/list-name"
- description: "Autolink list that contains a number"
text: "text @username/list123"
expected: "text @username/list123"
- description: "DO NOT Autolink list starting with a number"
text: "@username/1list"
expected: "@username/1list"
hashtags:
- description: "Autolink trailing hashtag"
text: "text #hashtag"
expected: "text #hashtag"
- description: "Autolink alphanumeric hashtag (letter-number-letter)"
text: "text #hash0tag"
expected: "text #hash0tag"
- description: "Autolink alphanumeric hashtag (number-letter)"
text: "text #1tag"
expected: "text #1tag"
- description: "Autolink hashtag with underscore"
text: "text #hash_tag"
expected: "text #hash_tag"
- 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: "DO NOT Autolink hashtag that begins with \ufe0f (Emoji style hash sign)"
text: "#️hashtag"
expected: "#️hashtag"
- description: "DO NOT Autolink hashtag that begins with \ufe0f (Keycap style hash sign)"
text: "#⃣hashtag"
expected: "#⃣hashtag"
- description: "Autolink multiple hashtags"
text: "text #hashtag1 #hashtag2"
expected: "text #hashtag1#hashtag2"
- description: "Autolink hashtag preceded by a period"
text: "text.#hashtag"
expected: "text.#hashtag"
- description: "DO NOT Autolink hashtag preceded by &"
text: "nbsp;"
expected: "nbsp;"
- description: "Autolink hashtag followed by ! (! not included)"
text: "text #hashtag!"
expected: "text #hashtag!"
- description: "Autolink two hashtags separated by a slash"
text: "text #dodge/#answer"
expected: "text #dodge/#answer"
- description: "Autolink hashtag before a slash"
text: "text #dodge/answer"
expected: "text #dodge/answer"
- description: "Autolink hashtag after a slash"
text: "text dodge/#answer"
expected: "text dodge/#answer"
- description: "Autolink hashtag followed by Japanese"
text: "text #hashtagの"
expected: "text #hashtagの"
- description: "Autolink hashtag preceded by full-width space (U+3000)"
text: "text #hashtag"
expected: "text #hashtag"
- description: "Autolink hashtag followed by full-width space (U+3000)"
text: "#hashtag text"
expected: "#hashtag text"
- description: "Autolink hashtag with full-width hash (U+FF03)"
text: "#hashtag"
expected: "#hashtag"
- description: "Autolink hashtag with accented character at the start"
text: "#éhashtag"
expected: "#éhashtag"
- description: "Autolink hashtag with accented character at the end"
text: "#hashtagé"
expected: "#hashtagé"
- description: "Autolink hashtag with accented character in the middle"
text: "#hashétag"
expected: "#hashétag"
- description: "Autolink hashtags in Korean"
text: "What is #트위터 anyway?"
expected: "What is #트위터 anyway?"
- description: "Autolink hashtags in Russian"
text: "What is #ашок anyway?"
expected: "What is #ашок anyway?"
- description: "Autolink a katakana hashtag preceded by a space and followed by a space"
text: "カタカナ #カタカナ カタカナ"
expected: "カタカナ #カタカナ カタカナ"
- description: "Autolink a katakana hashtag preceded by a space and followed by a bracket"
text: "カタカナ #カタカナ」カタカナ"
expected: "カタカナ #カタカナ」カタカナ"
- description: "Autolink a katakana hashtag preceded by a space and followed by a edge"
text: "カタカナ #カタカナ"
expected: "カタカナ #カタカナ"
- description: "Autolink a katakana hashtag preceded by a bracket and followed by a space"
text: "カタカナ「#カタカナ カタカナ"
expected: "カタカナ「#カタカナ カタカナ"
- description: "Autolink a katakana hashtag preceded by a bracket and followed by a bracket"
text: "カタカナ「#カタカナ」カタカナ"
expected: "カタカナ「#カタカナ」カタカナ"
- description: "Autolink a katakana hashtag preceded by a bracket and followed by a edge"
text: "カタカナ「#カタカナ"
expected: "カタカナ「#カタカナ"
- description: "Autolink a katakana hashtag preceded by a edge and followed by a space"
text: "#カタカナ カタカナ"
expected: "#カタカナ カタカナ"
- description: "Autolink a katakana hashtag preceded by a edge and followed by a bracket"
text: "#カタカナ」カタカナ"
expected: "#カタカナ」カタカナ"
- description: "Autolink a katakana hashtag preceded by a edge and followed by a edge"
text: "#カタカナ"
expected: "#カタカナ"
- description: "Autolink a katakana hashtag with a voiced sounds mark followed by a space"
text: "#ハッシュタグ テスト"
expected: "#ハッシュタグ テスト"
- description: "Autolink a katakana hashtag with a voiced sounds mark followed by numbers"
text: "#ハッシュタグ123"
expected: "#ハッシュタグ123"
- description: "Autolink a katakana hashtag with another voiced sounds mark"
text: "#パピプペポ"
expected: "#パピプペポ"
- description: "Autolink a kanji hashtag preceded by a space and followed by a space"
text: "漢字 #漢字 漢字"
expected: "漢字 #漢字 漢字"
- description: "Autolink a kanji hashtag preceded by a space and followed by a bracket"
text: "漢字 #漢字」漢字"
expected: "漢字 #漢字」漢字"
- description: "Autolink a kanji hashtag preceded by a space and followed by a edge"
text: "漢字 #漢字"
expected: "漢字 #漢字"
- description: "Autolink a kanji hashtag preceded by a bracket and followed by a space"
text: "漢字「#漢字 漢字"
expected: "漢字「#漢字 漢字"
- description: "Autolink a kanji hashtag preceded by a bracket and followed by a bracket"
text: "漢字「#漢字」漢字"
expected: "漢字「#漢字」漢字"
- description: "Autolink a kanji hashtag preceded by a bracket and followed by a edge"
text: "漢字「#漢字"
expected: "漢字「#漢字"
- description: "Autolink a kanji hashtag preceded by a edge and followed by a space"
text: "#漢字 漢字"
expected: "#漢字 漢字"
- description: "Autolink a kanji hashtag preceded by a edge and followed by a bracket"
text: "#漢字」漢字"
expected: "#漢字」漢字"
- description: "Autolink a kanji hashtag preceded by a edge and followed by a edge"
text: "#漢字"
expected: "#漢字"
- description: "Autolink a kanji hashtag preceded by an ideographic comma, followed by an ideographic period"
text: "これは、#大丈夫。"
expected: "これは、#大丈夫。"
- description: "Autolink a hiragana hashtag preceded by a space and followed by a space"
text: "ひらがな #ひらがな ひらがな"
expected: "ひらがな #ひらがな ひらがな"
- description: "Autolink a hiragana hashtag preceded by a space and followed by a bracket"
text: "ひらがな #ひらがな」ひらがな"
expected: "ひらがな #ひらがな」ひらがな"
- description: "Autolink a hiragana hashtag preceded by a space and followed by a edge"
text: "ひらがな #ひらがな"
expected: "ひらがな #ひらがな"
- description: "Autolink a hiragana hashtag preceded by a bracket and followed by a space"
text: "ひらがな「#ひらがな ひらがな"
expected: "ひらがな「#ひらがな ひらがな"
- description: "Autolink a hiragana hashtag preceded by a bracket and followed by a bracket"
text: "ひらがな「#ひらがな」ひらがな"
expected: "ひらがな「#ひらがな」ひらがな"
- description: "Autolink a hiragana hashtag preceded by a bracket and followed by a edge"
text: "ひらがな「#ひらがな"
expected: "ひらがな「#ひらがな"
- description: "Autolink a hiragana hashtag preceded by a edge and followed by a space"
text: "#ひらがな ひらがな"
expected: "#ひらがな ひらがな"
- description: "Autolink a hiragana hashtag preceded by a edge and followed by a bracket"
text: "#ひらがな」ひらがな"
expected: "#ひらがな」ひらがな"
- description: "Autolink a hiragana hashtag preceded by a edge and followed by a edge"
text: "#ひらがな"
expected: "#ひらがな"
- description: "Autolink a Kanji/Katakana mix hashtag"
text: "日本語ハッシュタグ #日本語ハッシュタグ"
expected: "日本語ハッシュタグ #日本語ハッシュタグ"
- description: "DO NOT autolink a hashtag without a preceding space"
text: "日本語ハッシュタグ#日本語ハッシュタグ"
expected: "日本語ハッシュタグ#日本語ハッシュタグ"
- description: "DO NOT include a punctuation in a hashtag"
text: "#日本語ハッシュタグ。"
expected: "#日本語ハッシュタグ。"
- description: "Autolink a hashtag after a punctuation"
text: "日本語ハッシュタグ。#日本語ハッシュタグ"
expected: "日本語ハッシュタグ。#日本語ハッシュタグ"
- description: "Autolink a hashtag with chouon"
text: "長音ハッシュタグ。#サッカー"
expected: "長音ハッシュタグ。#サッカー"
- description: "Autolink a hashtag with half-width chouon"
text: "長音ハッシュタグ。#サッカー"
expected: "長音ハッシュタグ。#サッカー"
- description: "Autolink a hashtag with half-width # after full-width !"
text: "できましたよー!#日本語ハッシュタグ。"
expected: "できましたよー!#日本語ハッシュタグ。"
- description: "Autolink a hashtag with full-width # after full-width !"
text: "できましたよー!#日本語ハッシュタグ。"
expected: "できましたよー!#日本語ハッシュタグ。"
- description: "Autolink a hashtag containing ideographic iteration mark"
text: "#云々"
expected: "#云々"
- description: "Autolink multiple hashtags in multiple languages"
text: "Hashtags in #中文, #日本語, #한국말, and #русский! Try it out!"
expected: "Hashtags in #中文, #日本語, #한국말, and #русский! Try it out!"
- description: "Autolink should allow for ş (U+015F) in a hashtag"
text: "Here’s a test tweet for you: #Ateş #qrşt #ştu #ş"
expected: "Here’s a test tweet for you: #Ateş#qrşt#ştu#ş"
- description: "Autolink a hashtag with Latin extended character"
text: "#mûǁae"
expected: "#mûǁae"
# Please be careful with changes to this test case - what looks like "á" is really a + U+0301, and many editors will silently convert this to U+00E1.
- description: "Autolink hashtags with combining diacritics"
text: "#táim #hag̃ua"
expected: "#táim#hag̃ua"
- description: "Autolink Arabic hashtag"
text: "Arabic hashtag: #فارسی #لس_آنجلس"
expected: "Arabic hashtag: #فارسی#لس_آنجلس"
- description: "Autolink Thai hashtag"
text: "Thai hashtag: #รายละเอียด"
expected: "Thai hashtag: #รายละเอียด"
urls:
- description: "Autolink URL with pipe character"
text: "text http://example.com/pipe|character?yes|pipe|character"
expected: "text http://example.com/pipe|character?yes|pipe|character"
- description: "Autolink trailing url"
text: "text http://example.com"
expected: "text http://example.com"
- description: "Autolink url in mid-text"
text: "text http://example.com more text"
expected: "text http://example.com more text"
- description: "Autolink url in Japanese text"
text: "いまなにしてるhttp://example.comいまなにしてる"
expected: "いまなにしてるhttp://example.comいまなにしてる"
- description: "Autolink url surrounded by parentheses does not capture them"
text: "text (http://example.com)"
expected: "text (http://example.com)"
- description: "Autolink url with path surrounded by parentheses does not capture them"
text: "text (http://example.com/test)"
expected: "text (http://example.com/test)"
- description: "Autolink url with embedded parentheses"
text: "text http://msdn.com/S(deadbeef)/page.htm"
expected: "text http://msdn.com/S(deadbeef)/page.htm"
- description: "Autolink url with embedded parentheses without linking surrounding parentheses"
text: "text (URL in parentheses http://msdn.com/S(deadbeef))"
expected: "text (URL in parentheses http://msdn.com/S(deadbeef))"
- description: "Autolink Rdio #music url with double balanced nested parentheses"
text: "text https://rdio.com/artist/50_Cent/album/We_Up/track/We_Up_(Album_Version_(Edited))/"
expected: "text https://rdio.com/artist/50_Cent/album/We_Up/track/We_Up_(Album_Version_(Edited))/"
- description: "Autolink Rdio #music url with double balanced nested parentheses without linking surrounding parentheses"
text: "text (URL in parentheses https://rdio.com/artist/50_Cent/album/We_Up/track/We_Up_(Album_Version_(Edited))/)"
expected: "text (URL in parentheses https://rdio.com/artist/50_Cent/album/We_Up/track/We_Up_(Album_Version_(Edited))/)"
- description: "Autolink url followed by nested parentheses (without them)"
text: "text https://rdio.com/artist/50_Cent/album/We_Up/track/We_Up(URL description with spaces and (parentheses))"
expected: "text https://rdio.com/artist/50_Cent/album/We_Up/track/We_Up(URL description with spaces and (parentheses))"
- description: "Autolink url followed by completely unbalanced nested parentheses (without them)"
text: "text https://rdio.com/artist/50_Cent/album/We_Up/track/We_Up_(Album_Version_(Edited"
expected: "text https://rdio.com/artist/50_Cent/album/We_Up/track/We_Up_(Album_Version_(Edited"
- description: "Extract valid URL: http://msdn.microsoft.com/ja-jp/library/system.net.httpwebrequest(v=VS.100).aspx"
text: "text http://msdn.microsoft.com/ja-jp/library/system.net.httpwebrequest(v=VS.100).aspx"
expected: "text http://msdn.microsoft.com/ja-jp/library/system.net.httpwebrequest(v=VS.100).aspx"
- description: "Autolink url with balanced parens hiding XSS"
text: 'text http://foo.com/("onclick="alert(1)")'
expected: 'text http://foo.com/("onclick="alert(1)")'
- description: "Autolink url should NOT capture unbalanced parens"
text: "Parenthetically bad http://example.com/i_has_a_) thing"
expected: "Parenthetically bad http://example.com/i_has_a_) thing"
- description: "Autolink url containing unicode characters"
text: "I enjoy Macintosh Brand computers: http://✪df.ws/ejp"
expected: "I enjoy Macintosh Brand computers: http://✪df.ws/ejp"
- description: "Autolink url with .co. under TLD"
text: "test http://www.example.co.jp"
expected: "test http://www.example.co.jp"
- description: "Autolink url with .sx TLD"
text: "test http://www.example.sx"
expected: "test http://www.example.sx"
- description: "DO NOT Autolink url containing ! character in the domain"
text: "badly formatted http://foo!bar.com"
expected: "badly formatted http://foo!bar.com"
- description: "DO NOT Autolink url containing _ character in the domain"
text: "badly formatted http://foo_bar.com"
expected: "badly formatted http://foo_bar.com"
- description: "Autolink url preceded by :"
text: "text:http://example.com"
expected: "text:http://example.com"
- description: "Autolink url followed by ? (without it)"
text: "text http://example.com?"
expected: "text http://example.com?"
- description: "Autolink url followed by ! (without it)"
text: "text http://example.com!"
expected: "text http://example.com!"
- description: "Autolink url followed by , (without it)"
text: "text http://example.com,"
expected: "text http://example.com,"
- description: "Autolink url with path followed by a comma (wihout the comma)"
text: "In http://example.com/test, Douglas explains 42."
expected: "In http://example.com/test, Douglas explains 42."
- description: "Autolink url followed by . (without it)"
text: "text http://example.com."
expected: "text http://example.com."
- description: "Autolink url followed by : (without it)"
text: "text http://example.com:"
expected: "text http://example.com:"
- description: "Autolink url followed by ; (without it)"
text: "text http://example.com;"
expected: "text http://example.com;"
- description: "Autolink url followed by ] (without it)"
text: "text http://example.com]"
expected: "text http://example.com]"
- description: "Autolink url followed by ) (without it)"
text: "text http://example.com)"
expected: "text http://example.com)"
- description: "Autolink url followed by } (without it)"
text: "text http://example.com}"
expected: "text http://example.com}"
- description: "Autolink url followed by = (without it)"
text: "text http://example.com="
expected: "text http://example.com="
- description: "Autolink url followed by ' (without it)"
text: "text http://example.com'"
expected: "text http://example.com'"
- description: "Autolink url preceded by /"
text: "text /http://example.com"
expected: "text /http://example.com"
- description: "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 surrounded by double quotes"
text: "text \"http://example.com\""
expected: "text \"http://example.com\""
- description: "DO NOT Autolink url preceded by @"
text: "@http://example.com"
expected: "@http://example.com"
- description: "DO NOT Autolink domain in email address"
text: "foo@bar.com"
expected: "foo@bar.com"
- description: "Autolink url embedded in link tag"
text: "http://example.com"
expected: "http://example.com"
- description: "Autolink multiple urls"
text: "http://example.com https://sslexample.com http://sub.example.com"
expected: "http://example.comhttps://sslexample.comhttp://sub.example.com"
- description: "Autolink url with long TLD"
text: "http://example.mobi/path"
expected: "http://example.mobi/path"
- description: "Autolink url containing ending with #value (not as url + hashtag)"
text: "http://foo.com/?#foo"
expected: "http://foo.com/?#foo"
- description: "DO NOT Autolink url without protocol (with www)"
text: "www.example.biz"
expected: "www.example.biz"
- description: "DO NOT Autolink url without protocol (with WWW)"
text: "WWW.EXAMPLE.BIZ"
expected: "WWW.EXAMPLE.BIZ"
- description: "DO NOT Autolink URL without protocol and without www (ending in .com)"
text: "foo.com"
expected: "foo.com"
- description: "DO NOT Autolink URL without protocol and without www (ending in .org)"
text: "foo.org"
expected: "foo.org"
- description: "DO NOT Autolink URL without protocol and without www (ending in .net)"
text: "foo.net"
expected: "foo.net"
- description: "DO NOT Autolink URL without protocol and without www (ending in .gov)"
text: "foo.gov"
expected: "foo.gov"
- description: "DO NOT Autolink URL without protocol and without www (ending in .edu)"
text: "foo.edu"
expected: "foo.edu"
- description: "DO NOT Autolink URL without protocol and without www not ending in /.(edu|com|gov|org|net)/"
text: "foo.it twitter.co.jp foo.commerce foo.nettastic foo.us foo.co.uk"
expected: "foo.it twitter.co.jp foo.commerce foo.nettastic foo.us foo.co.uk"
- description: "Multiple URLs with different protocols but not without a protocol"
text: "http://foo.com AND https://bar.com AND www.foobar.com"
expected: "http://foo.com AND https://bar.com AND www.foobar.com"
- description: "Autolink raw domain followed by domain only links the first"
text: "See http://example.com example.com"
expected: "See http://example.com example.com"
- description: "Autolink url that includes @-sign and numeric dir under it"
text: "http://www.flickr.com/photos/29674651@N00/4382024406"
expected: "http://www.flickr.com/photos/29674651@N00/4382024406"
- description: "Autolink url that includes @-sign and non-numeric dir under it"
text: "http://www.flickr.com/photos/29674651@N00/foobar"
expected: "http://www.flickr.com/photos/29674651@N00/foobar"
- description: "Autolink url with a hashtag-looking fragment"
text: "http://www.example.com/#answer"
expected: "http://www.example.com/#answer"
- description: "Autolink URL with only a domain followed by a period doesn't swallow the period."
text: "I think it's proper to end sentences with a period http://tell.me.com. Even when they contain a URL."
expected: "I think it's proper to end sentences with a period http://tell.me.com. Even when they contain a URL."
- description: "Autolink URL with a path followed by a period doesn't swallow the period."
text: "I think it's proper to end sentences with a period http://tell.me/why. Even when they contain a URL."
expected: "I think it's proper to end sentences with a period http://tell.me/why. Even when they contain a URL."
- description: "Autolink URL with a query followed by a period doesn't swallow the period."
text: "I think it's proper to end sentences with a period http://tell.me/why?=because.i.want.it. Even when they contain a URL."
expected: "I think it's proper to end sentences with a period http://tell.me/why?=because.i.want.it. Even when they contain a URL."
- description: "Autolink URL with a hyphen in the domain name"
text: "Czech out sweet deals at http://mrs.domain-dash.biz ok?"
expected: "Czech out sweet deals at http://mrs.domain-dash.biz ok?"
- description: "Autolink an IDN (punycode) domain and TLD"
text: "See also: http://xn--80abe5aohbnkjb.xn--p1ai/"
expected: "See also: http://xn--80abe5aohbnkjb.xn--p1ai/"
- description: "Autolink URL should NOT autolink www...foo"
text: "Is www...foo a valid URL?"
expected: "Is www...foo a valid URL?"
- description: "Autolink URL should NOT autolink www.-foo.com"
text: "Is www.-foo.com a valid URL?"
expected: "Is www.-foo.com a valid URL?"
- description: "Autolink URL should NOT autolink a domain with a valid dash but no protocol"
text: "Is www.foo-bar.com a valid URL?"
expected: "Is www.foo-bar.com a valid URL?"
- description: "Autolink URL should autolink a domain with a valid dash and a protocol"
text: "Is http://www.foo-bar.com a valid URL?"
expected: "Is http://www.foo-bar.com a valid URL?"
- description: "Autolink URL should link search urls (with &lang=, not 〈)"
text: "Check out http://search.twitter.com/search?q=avro&lang=en"
expected: "Check out http://search.twitter.com/search?q=avro&lang=en"
- description: "Autolink URL should link urls with very long paths"
text: "Check out http://example.com/aaaaaaaaaa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ow;color:yellow;\"/"
expected: "example: https://twitter.com/otm_m@\"onmousedown=\"alert('foo')\" style=background-color:yellow;color:yellow;\"/"
- description: "Autolink URL should autolink a URL with a - or + at the end of the path"
text: "Go to http://example.com/a+ or http://example.com/a-"
expected: "Go to http://example.com/a+ or http://example.com/a-"
- description: "Autolink URL should autolink a URL with a - or + at the end of the path and query parameters"
text: "Go to http://example.com/a+?this=that or http://example.com/a-?this=that"
expected: "Go to http://example.com/a+?this=that or http://example.com/a-?this=that"
- description: "Autolink URL should autolink URLs with longer paths ending in -"
text: "Go to http://example.com/view/slug-url-?foo=bar"
expected: "Go to http://example.com/view/slug-url-?foo=bar"
- description: "Autolink URL should NOT link URLs with domains beginning in a space"
text: "@user Try http:// example.com/path"
expected: "@user Try http:// example.com/path"
- description: "Autolink URL should NOT link URLs with domains beginning in a non-breaking space (U+00A0)"
text: "@user Try http:// example.com/path"
expected: "@user Try http:// example.com/path"
- description: "Autolink URL should link paths containing accented characters"
text: "See: http://example.com/café"
expected: "See: http://example.com/café"
- description: "Autolink URL should link paths containing Cyrillic characters"
text: "Go to http://example.com/Русские_слова maybe?"
expected: "Go to http://example.com/Русские_слова maybe?"
- description: "Autolink URL should not link URL without protocol"
text: "See: www.twitter.com or twitter.com/twitter"
expected: "See: www.twitter.com or twitter.com/twitter"
- description: "Autolink t.co URL followed by punctuation"
text: "See: http://t.co/abcde's page"
expected: "See: http://t.co/abcde's page"
- description: "DO NOT autolink URL if preceded by $"
text: "$https://twitter.com $twitter.com $http://t.co/abcde $t.co/abcde $t.co $TVI.CA $RBS.CA"
expected: "$https://twitter.com $twitter.com $http://t.co/abcde $t.co/abcde $t.co $TVI.CA $RBS.CA"
cashtags:
- description: "Autolink a cashtag"
text: "$STOCK"
expected: "$STOCK"
- description: "Autolink a cashtag in text"
text: "Text $STOCK text $symbol text"
expected: "Text $STOCK text $symbol text"
all:
- description: "Autolink all does not break on URL with @"
text: "http://www.flickr.com/photos/29674651@N00/4382024406 if you know what's good for you."
expected: "http://www.flickr.com/photos/29674651@N00/4382024406 if you know what's good for you."
- description: "Correctly handles URL followed directly by @user"
text: "See: http://example.com/@user"
expected: "See: http://example.com/@user"
- description: "Correctly handles URL params containing @user"
text: "See: http://example.com/?@user=@user"
expected: "See: http://example.com/?@user=@user"
- description: "Correctly handles URL with an @user followed by trailing /"
text: "See: http://example.com/@user/"
expected: "See: http://example.com/@user/"
- description: "Does not allow an XSS after an @"
text: "See: http://x.xx.com/@\"style=\"color:pink\"onmouseover=alert(1)//"
expected: "See: http://x.xx.com/@\"style=\"color:pink\"onmouseover=alert(1)//"
- description: "DO NOT autolink URLs if preceded by # or @"
text: "#https://twitter.com @https://twitter.com"
expected: "#https://twitter.com @https://twitter.com"
- description: "Autolink url with a hashtag-looking fragment"
text: "http://www.example.com/#answer"
expected: "http://www.example.com/#answer"
- description: "Autolink hashtag if followed by . and TLD"
text: "#twitter.com #twitter.co.jp"
expected: "#twitter.com #twitter.co.jp"
- description: "Autolink @mention if followed by . and TLD"
text: "@twitter.com @twitter.co.jp"
expected: "@twitter.com @twitter.co.jp"
- description: "Autolink a cashtag"
text: "$STOCK"
expected: "$STOCK"
json:
- description: "Do not autolink if JSON is empty."
text: "This is a tweet with no entity."
json: '{"hashtags":[], "urls":[], "user_mentions":[]}'
expected: "This is a tweet with no entity."
- description: "Autolink username"
text: "text @username"
json: '{"hashtags":[], "urls":[], "user_mentions":[{"screen_name": "username", "name": "@username", "id": 318686216, "id_str": "318686216", "indices": [5, 14]}]}'
expected: "text @username"
- description: "Autolink hashtag"
text: "text #hashtag"
json: '{"hashtags":[{"text":"hashtag", "indices":[5,13]}], "urls":[], "user_mentions":[]}'
expected: "text #hashtag"
- description: "Autolink URL"
text: "text http://t.co/gksG6xlq"
json: '{"hashtags":[], "urls":[{"url": "http://t.co/gksG6xlq", "expanded_url": "http://twitter.com/", "display_url": "twitter.com", "indices": [5, 25]}], "user_mentions":[]}'
expected: "text http://twitter.com/"
- description: "Autolink all"
text: "text http://t.co/gksG6xlq text #hashtag text @username"
json: '{"hashtags":[{"text":"hashtag", "indices":[31,39]}], "urls":[{"url": "http://t.co/gksG6xlq", "expanded_url": "http://twitter.com/", "display_url": "twitter.com", "indices": [5, 25]}], "user_mentions":[{"screen_name": "username", "name": "@username", "id": 318686216, "id_str": "318686216", "indices": [45, 54]}]}'
expected: "text http://twitter.com/ text #hashtag text @username"