You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it("should NOT automatically link URLs within HTML tags",function(){
157
-
varresult=Autolinker.link('<p>Joe went to <a href="http://www.yahoo.com">yahoo</a></p>');
158
-
expect(result).toBe('<p>Joe went to <a href="http://www.yahoo.com">yahoo</a></p>');
159
-
});
160
-
161
-
162
156
it("should automatically link URLs past the last HTML tag",function(){
163
157
varresult=Autolinker.link('<p>Joe went to <a href="http://www.yahoo.com">yahoo</a></p> and http://google.com');
164
158
expect(result).toBe('<p>Joe went to <a href="http://www.yahoo.com">yahoo</a></p> and <a href="http://google.com" target="_blank">google.com</a>');
165
159
});
166
160
167
161
168
-
it("should NOT automatically link a URL found within the inner text of a pre-existing anchor tag",function(){
169
-
varresult=Autolinker.link('<p>Joe went to <a href="http://www.yahoo.com">yahoo.com</a></p> yesterday.');
170
-
expect(result).toBe('<p>Joe went to <a href="http://www.yahoo.com">yahoo.com</a></p> yesterday.');
171
-
});
172
-
173
-
174
-
it("should NOT automatically link a URL found within the inner text of a pre-existing anchor tag, but link others",function(){
175
-
varresult=Autolinker.link('<p>Joe went to google.com, <a href="http://www.yahoo.com">yahoo.com</a>, and weather.com</p> yesterday.');
176
-
expect(result).toBe('<p>Joe went to <a href="http://google.com" target="_blank">google.com</a>, <a href="http://www.yahoo.com">yahoo.com</a>, and <a href="http://weather.com" target="_blank">weather.com</a></p> yesterday.');
177
-
});
178
-
179
-
180
-
it("should NOT automatically link an image tag with a URL inside it, inside an anchor tag",function(){
autolinker=newAutolinker({newWindow: false});// just to stop the target="_blank" from coming into the autolinked results
185
+
});
186
+
187
+
188
+
it("should NOT automatically link URLs within existing HTML tags",function(){
189
+
varresult=autolinker.link('<p>Joe went to <a href="http://www.yahoo.com">yahoo</a></p>');
190
+
expect(result).toBe('<p>Joe went to <a href="http://www.yahoo.com">yahoo</a></p>');
191
+
});
192
+
193
+
194
+
it("should NOT automatically link a URL found within the inner text of a pre-existing anchor tag",function(){
195
+
varresult=autolinker.link('<p>Joe went to <a href="http://www.yahoo.com">yahoo.com</a></p> yesterday.');
196
+
expect(result).toBe('<p>Joe went to <a href="http://www.yahoo.com">yahoo.com</a></p> yesterday.');
197
+
});
198
+
199
+
200
+
it("should NOT automatically link a URL found within the inner text of a pre-existing anchor tag, but link others",function(){
201
+
varresult=autolinker.link('<p>Joe went to google.com, <a href="http://www.yahoo.com">yahoo.com</a>, and weather.com</p> yesterday.');
202
+
expect(result).toBe('<p>Joe went to <a href="http://google.com">google.com</a>, <a href="http://www.yahoo.com">yahoo.com</a>, and <a href="http://weather.com">weather.com</a></p> yesterday.');
203
+
});
204
+
205
+
206
+
it("should NOT automatically link an image tag with a URL inside it, inside an anchor tag",function(){
it("should allow the full range of HTML attribute name characters as specified in the W3C HTML syntax document (http://www.w3.org/TR/html-markup/syntax.html)",function(){
213
219
// Note: We aren't actually expecting the HTML to be modified by this test
it("should properly autolink text within namespaced HTML elements, skipping over html elements with urls in attribute values",function(){
220
226
varhtml='<ns:p>Go to google.com or <a data-qux-="test" href="http://www.example.com" target="_blank">Bar<\/a> Baz<\/ns:p>';
221
227
222
-
varresult=Autolinker.link(html,{newWindow: false});// newWindow: false just to remove target="_blank" from the generated anchor
228
+
varresult=autolinker.link(html);
223
229
expect(result).toBe('<ns:p>Go to <a href="http://google.com">google.com</a> or <a data-qux-="test" href="http://www.example.com" target="_blank">Bar<\/a> Baz<\/ns:p>');
224
230
});
225
231
226
232
227
233
it("should properly skip over attribute names that could be interpreted as urls, while still autolinking urls in their inner text",function(){
228
234
varhtml='<div google.com anotherAttr yahoo.com>My div that has an attribute of google.com</div>';
expect(result).toBe('<div google.com anotherAttr yahoo.com>My div that has an attribute of <a href="http://google.com">google.com</a></div>');
232
238
});
233
239
234
240
235
241
it("should properly skip over attribute names that could be interpreted as urls when they have a value, while still autolinking urls in their inner text",function(){
236
242
varhtml='<div google.com="yes" anotherAttr=true yahoo.com="true">My div that has an attribute of google.com</div>';
expect(result).toBe('<div google.com="yes" anotherAttr=true yahoo.com="true">My div that has an attribute of <a href="http://google.com">google.com</a></div>');
240
246
});
241
247
242
248
243
249
it("should properly skip over attribute names that could be interpreted as urls when they have a value and any number of spaces between attrs, while still autolinking urls in their inner text",function(){
244
250
varhtml='<div google.com="yes" \t\t anotherAttr=true yahoo.com="true" \t>My div that has an attribute of google.com</div>';
expect(result).toBe('<div google.com="yes" \t\t anotherAttr=true yahoo.com="true" \t>My div that has an attribute of <a href="http://google.com">google.com</a></div>');
248
254
});
249
255
250
256
251
257
it("should properly skip over attribute values that could be interpreted as urls/emails/twitter accts, while still autolinking urls in their inner text",function(){
it("should properly skip over attribute names and values that could be interpreted as urls/emails/twitter accts, while still autolinking urls in their inner text",function(){
0 commit comments