Made URL-detecting regular expression better
the build was successful Details

fixes #1
This commit is contained in:
tastytea 2018-06-28 13:34:51 +02:00
parent 23ad1917f9
commit 52604d536a
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
2 changed files with 9 additions and 5 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7)
project (expandurl-mastodon
VERSION 0.9.9
VERSION 0.9.10
LANGUAGES CXX
)

View File

@ -31,16 +31,20 @@ namespace curlopts = curlpp::options;
const std::vector<string> get_urls(const string &html)
{
const std::regex re_url("href=\"([^\"]+)\" rel");
const std::regex re_url("href=\\\\?\"([^\"\\\\]+)\\\\?\"([^>]+)");
std::smatch match;
string buffer = html;
std::vector<string> v;
while (std::regex_search(buffer, match, re_url))
{
string url = Easy::unescape_html(match[1].str());
v.push_back(strip(expand(url)));
buffer = match.suffix().str();
// Add URL to vector if it is not a mention.#
if (match[2].str().find("mention") == std::string::npos)
{
string url = Easy::unescape_html(match[1].str());
v.push_back(strip(expand(url)));
buffer = match.suffix().str();
}
}
return v;