diff options
| author | Remko Tronçon <git@el-tramo.be> | 2009-11-16 18:20:52 (GMT) |
|---|---|---|
| committer | Remko Tronçon <git@el-tramo.be> | 2009-11-16 18:20:52 (GMT) |
| commit | b793111e4e4bbbe6738e4d0838e9a99b3580549d (patch) | |
| tree | 7ad1e14e80d71229204fa3234294187353e1e28c | |
| parent | 05111e25fd10aa140cd823d37ca884b73dad2725 (diff) | |
| download | swift-b793111e4e4bbbe6738e4d0838e9a99b3580549d.zip swift-b793111e4e4bbbe6738e4d0838e9a99b3580549d.tar.bz2 | |
Fixed Linkify on camel case URLs.
| -rw-r--r-- | SwifTools/Linkify.cpp | 2 | ||||
| -rw-r--r-- | SwifTools/UnitTest/LinkifyTest.cpp | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/SwifTools/Linkify.cpp b/SwifTools/Linkify.cpp index 8654307..8cc169b 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 9b66614..a249d48 100644 --- a/SwifTools/UnitTest/LinkifyTest.cpp +++ b/SwifTools/UnitTest/LinkifyTest.cpp @@ -9,12 +9,13 @@ class LinkifyTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(LinkifyTest); CPPUNIT_TEST(testLinkify_URLWithResource); CPPUNIT_TEST(testLinkify_URLWithEmptyResource); CPPUNIT_TEST(testLinkify_BareURL); CPPUNIT_TEST(testLinkify_URLSurroundedByWhitespace); CPPUNIT_TEST(testLinkify_MultipleURLs); + CPPUNIT_TEST(testLinkify_CamelCase); CPPUNIT_TEST_SUITE_END(); public: void testLinkify_URLWithResource() { String result = Linkify::linkify("http://swift.im/blog"); @@ -52,9 +53,17 @@ class LinkifyTest : public CppUnit::TestFixture { String result = Linkify::linkify("Foo http://swift.im/blog Bar http://el-tramo.be/about Baz"); CPPUNIT_ASSERT_EQUAL( String("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar <a href=\"http://el-tramo.be/about\">http://el-tramo.be/about</a> Baz"), result); } + + void testLinkify_CamelCase() { + String result = Linkify::linkify("http://fOo.cOm/bAz"); + + CPPUNIT_ASSERT_EQUAL( + String("<a href=\"http://fOo.cOm/bAz\">http://fOo.cOm/bAz</a>"), + result); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(LinkifyTest); |
Swift