=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/TextUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/TextUtils.java 2012-02-08 16:08:43 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/TextUtils.java 2012-02-09 18:32:12 +0000
@@ -39,7 +39,7 @@
{
public static final TextUtils INSTANCE = new TextUtils();
- private static final Pattern LINK_PATTERN = Pattern.compile( "(http://|https://|www\\.).+?($| )" );
+ private static final Pattern LINK_PATTERN = Pattern.compile( "((http://|https://|www\\.).+?)($| )" );
/**
* Substitutes links in the given text with valid HTML mark-up. For instance,
@@ -62,15 +62,14 @@
while ( matcher.find() )
{
- String match = matcher.group();
-
- String suffix = match.endsWith( " " ) ? " " : "";
-
- String ref = match.trim().startsWith( "www." ) ? "http://" + match.trim() : match.trim();
-
- match = "" + match.trim() + "" + suffix;
-
- matcher.appendReplacement( buffer, match );
+ String url = matcher.group( 1 );
+ String suffix = matcher.group( 3 );
+
+ String ref = url.startsWith( "www." ) ? "http://" + url : url;
+
+ url = "" + url + "" + suffix;
+
+ matcher.appendReplacement( buffer, url );
}
return matcher.appendTail( buffer ).toString();