diff --git a/core/lib/utils/linkify_html.dart b/core/lib/utils/linkify_html.dart
index b0653417a..2c2372500 100644
--- a/core/lib/utils/linkify_html.dart
+++ b/core/lib/utils/linkify_html.dart
@@ -21,11 +21,16 @@ class LinkifyHtml {
final regexLinkWithHttp = _generateRegExp(r'(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])');
final newReplacedTextWithHttp = replacedText.replaceAllMapped(regexLinkWithHttp, (regexMatch) {
final link = regexMatch.group(1);
- final newLinkWithHttp = link?.isNotEmpty == true
- ? '$link'
- : '';
- log('ConvertUrlStringToHtmlLinksTransformers::_linkifyUrlAddress(): newLinkWithHttp: $newLinkWithHttp');
- return newLinkWithHttp;
+ log('LinkifyHtml::_linkifyUrlAddress():link: $link');
+ if (link?.isNotEmpty == true) {
+ if (replacedText.contains('$link';
+ }
+ } else {
+ return '';
+ }
});
replacedText = newReplacedTextWithHttp;
@@ -35,11 +40,16 @@ class LinkifyHtml {
final previousChar = regexMatch.group(1);
log('LinkifyHtml::_linkifyUrlAddress(): previousChar: $previousChar');
final link = regexMatch.group(2);
- final newLinkWithWWW = link?.isNotEmpty == true
- ? '$previousChar$link'
- : '';
- log('ConvertUrlStringToHtmlLinksTransformers::_linkifyUrlAddress(): newLinkWithWWW: $newLinkWithWWW');
- return newLinkWithWWW;
+ log('LinkifyHtml::_linkifyUrlAddress():link: $link');
+ if (link?.isNotEmpty == true) {
+ if (replacedText.contains('$link';
+ }
+ } else {
+ return '';
+ }
});
replacedText = newReplacedTextWithWWW;
@@ -52,11 +62,15 @@ class LinkifyHtml {
final newReplacedTextWitMailTo = inputText.replaceAllMapped(regexMailTo, (regexMatch) {
final emailAddress = regexMatch.group(1);
- final newMailToLink = emailAddress?.isNotEmpty == true
- ? '$emailAddress'
- : '';
- log('ConvertUrlStringToHtmlLinksTransformers::_linkifyUrlAddress(): newMailToLink: $newMailToLink');
- return newMailToLink;
+ if (emailAddress?.isNotEmpty == true) {
+ if (inputText.contains('$emailAddress';
+ }
+ } else {
+ return '';
+ }
});
return newReplacedTextWitMailTo;
diff --git a/core/test/linkify_html_test.dart b/core/test/linkify_html_test.dart
index 629f00ee0..00434a55f 100644
--- a/core/test/linkify_html_test.dart
+++ b/core/test/linkify_html_test.dart
@@ -42,5 +42,18 @@ void main() {
equals('See tdvu@linagora.com at Hanoi'));
}
);
+
+ test(
+ 'generateLinkify should preserve the text when input text contain james/ApacheJames/master [master] [765]"'
+ );
+ expect(
+ htmlValidate,
+ equals('Check console output at "james/ApacheJames/master [master] [765]"')
+ );
+ }
+ );
});
}
\ No newline at end of file