and ', () {
+ const html = 'https://example.com
www.site.com';
+ final out = HtmlUtils.wrapPlainTextLinks(html);
+
+ expect(out, contains('https://example.com
'));
+ expect(out, contains('www.site.com'));
+ expect(out, isNot(contains(''));
+ });
+
+ test('IP addresses: http + www.*', () {
+ const html = 'http://192.168.1.1 www.127.0.0.1';
+ final out = HtmlUtils.wrapPlainTextLinks(html);
+
+ expect(out, contains('http://192.168.1.1'));
+ expect(out, contains('www.127.0.0.1'));
+ });
+
+ test('URLs in blockquote/list/table are wrapped', () {
+ const html = '''
+ https://example.com
+
+
+ ''';
+ final out = HtmlUtils.wrapPlainTextLinks(html).replaceAll('\n', '');
+
+ expect(
+ out,
+ contains(
+ 'https://example.com
',
+ ),
+ );
+ expect(
+ out,
+ contains('www.site.com'),
+ );
+ expect(
+ out,
+ contains('https://abc.com | '),
+ );
+ });
+
+ test('Malformed URLs: no wrap', () {
+ const html = 'Wrong: http//example and www..com';
+ final out = HtmlUtils.wrapPlainTextLinks(html);
+
+ expect(out, isNot(contains('www.example1.comwww.example2.com',
+ ),
+ );
+ expect(out.indexOf(' (skip parent tag)', () {
+ const html =
+ 'https://example.com vĂ www.site.com';
+ final out = HtmlUtils.wrapPlainTextLinks(html);
+
+ expect(
+ out,
+ contains(
+ 'https://example.com',
+ ),
+ );
+ expect(
+ out,
+ contains('www.site.com'),
+ );
+ });
});
}
\ No newline at end of file