This repository has been archived by the owner on Sep 18, 2021. It is now read-only.
/
autolink.yml
305 lines (231 loc) · 15.6 KB
/
autolink.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
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 does not capture them"
text: "text (http://example.com)"
expected: "text (<a href=\"http://example.com\">http://example.com</a>)"
- description: "Autolink url with path surrounded by parentheses does not capture them"
text: "text (http://example.com/test)"
expected: "text (<a href=\"http://example.com/test\">http://example.com/test</a>)"
- description: "Autolink url with embedded parentheses"
text: "text http://msdn.com/S(deadbeef)/page.htm"
expected: "text (<a href=\"http://msdn.com/S(deadbeef)/page.htm\">http://msdn.com/S(deadbeef)/page.htm</a>"
- description: "Autolink url should NOT capture unbalanced parens"
text: "Parenthetically bad http://example.com/i_has_a_) thing"
expected: "Parenthetically bad <a href=\"http://example.com/i_has_a_\">http://example.com/i_has_a_</a>) thing"
- 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: "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:<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: "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>"
- description: "Multiple URLs with different protocols"
text: "http://foo.com AND https://bar.com AND www.foobar.com"
expected: "<a href=\"http://foo.com\">http://foo.com</a> AND <a href=\"https://bar.com\">https://bar.com</a> AND <a href=\"http://www.foobar.com\">www.foobar.com</a>"
- description: "Autolink raw domain followed by domain"
text: "See http://example.com example.com"
expected: "See <a href=\"http://example.com\">http://example.com</a> example.com"
- description: "Autolink url that includes @-sign and numeric dir under it"
text: "http://www.flickr.com/photos/29674651@N00/4382024406"
expected: "<a href=\"http://www.flickr.com/photos/29674651@N00/4382024406\">http://www.flickr.com/photos/29674651@N00/4382024406</a>"
- description: "Autolink url that includes @-sign and non-numeric dir under it"
text: "http://www.flickr.com/photos/29674651@N00/foobar"
expected: "<a href=\"http://www.flickr.com/photos/29674651@N00/foobar\">http://www.flickr.com/photos/29674651@N00/foobar</a>"
- 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. Even when they contain a URL."
expected: "I think it's proper to end sentences with a period <a href=\"http://tell.me\">http://tell.me</a>. 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 <a href=\"http://tell.me/why\">http://tell.me/why</a>. 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 <a href=\"http://tell.me/why?=because.i.want.it\">http://tell.me/why?=because.i.want.it</a>. Even when they contain a URL."
- 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 autolink a domain with a valid dash"
text: "Is www.foo-bar.com a valid URL?"
expected: "Is <a href=\"http://www.foo-bar.com\">www.foo-bar.com</a> 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 <a href=\"http://search.twitter.com/search?q=avro&lang=en\">http://search.twitter.com/search?q=avro&lang=en</a>"
all:
- description: "Autolink all does not break on URL with @"
text: "http://www.flickr.com/photos/29674651@N00/4382024406"
expected: "<a href=\"http://www.flickr.com/photos/29674651@N00/4382024406\">http://www.flickr.com/photos/29674651@N00/4382024406</a>"
- description: "Autolink all does not allow & without ?"
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>"