summaryrefslogtreecommitdiffstats
blob: 483a08f2c84e848f78e0c096a0111a789d93e28a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * Copyright (c) 2010 Remko Tronçon
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#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));
}

}