summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-11-15 13:03:05 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-11-15 13:33:17 (GMT)
commitbd4e48adb3f23f80abc8441bf359166fbe9b621c (patch)
tree9141e6e7c68e28e14961491459d5996a1d957067 /SwifTools/Linkify.cpp
parent22973faaced00f3307efbb8b8fc4e914de7023e8 (diff)
downloadswift-bd4e48adb3f23f80abc8441bf359166fbe9b621c.zip
swift-bd4e48adb3f23f80abc8441bf359166fbe9b621c.tar.bz2
Linkify URLs.
Diffstat (limited to 'SwifTools/Linkify.cpp')
-rw-r--r--SwifTools/Linkify.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/SwifTools/Linkify.cpp b/SwifTools/Linkify.cpp
new file mode 100644
index 0000000..8654307
--- /dev/null
+++ b/SwifTools/Linkify.cpp
@@ -0,0 +1,17 @@
+#include "SwifTools/Linkify.h"
+
+#include <boost/regex.hpp>
+
+namespace Swift {
+
+static const boost::regex linkifyRegexp("(https?://([-\\w\\.]+)+(:\\d+)?(/([%-\\w/_\\.]*(\\?\\S+)?)?)?)");
+
+String Linkify::linkify(const String& input) {
+ return String(boost::regex_replace(
+ input.getUTF8String(),
+ linkifyRegexp,
+ "<a href=\"\\1\">\\1</a>",
+ boost::match_default|boost::format_all));
+}
+
+}