summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--SwifTools/Linkify.cpp2
-rw-r--r--SwifTools/UnitTest/LinkifyTest.cpp9
2 files changed, 10 insertions, 1 deletions
diff --git a/SwifTools/Linkify.cpp b/SwifTools/Linkify.cpp
index 7fa8c91..63f06c8 100644
--- a/SwifTools/Linkify.cpp
+++ b/SwifTools/Linkify.cpp
@@ -1,13 +1,13 @@
#include "SwifTools/Linkify.h"
#include <boost/regex.hpp>
namespace Swift {
-static const boost::regex linkifyRegexp("(https?://([\\-\\w\\.]+)+(:\\d+)?(/([%\\-\\w/_#\\.]*(\\?\\S+)?)?)?)");
+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>",
diff --git a/SwifTools/UnitTest/LinkifyTest.cpp b/SwifTools/UnitTest/LinkifyTest.cpp
index b31bbfe..6c5fb15 100644
--- a/SwifTools/UnitTest/LinkifyTest.cpp
+++ b/SwifTools/UnitTest/LinkifyTest.cpp
@@ -12,12 +12,13 @@ class LinkifyTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testLinkify_BareURL);
CPPUNIT_TEST(testLinkify_URLSurroundedByWhitespace);
CPPUNIT_TEST(testLinkify_MultipleURLs);
CPPUNIT_TEST(testLinkify_CamelCase);
CPPUNIT_TEST(testLinkify_HierarchicalResource);
CPPUNIT_TEST(testLinkify_Anchor);
+ CPPUNIT_TEST(testLinkify_Plus);
CPPUNIT_TEST_SUITE_END();
public:
void testLinkify_URLWithResource() {
String result = Linkify::linkify("http://swift.im/blog");
@@ -79,9 +80,17 @@ class LinkifyTest : public CppUnit::TestFixture {
String result = Linkify::linkify("http://foo.com/bar#baz");
CPPUNIT_ASSERT_EQUAL(
String("<a href=\"http://foo.com/bar#baz\">http://foo.com/bar#baz</a>"),
result);
}
+
+ void testLinkify_Plus() {
+ String result = Linkify::linkify("http://foo.com/bar+baz");
+
+ CPPUNIT_ASSERT_EQUAL(
+ String("<a href=\"http://foo.com/bar+baz\">http://foo.com/bar+baz</a>"),
+ result);
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(LinkifyTest);