Made tracking-regexes case-insensitive

This commit is contained in:
tastytea 2018-05-21 14:36:00 +02:00
parent 7cc297ea16
commit 08bec96131
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
2 changed files with 6 additions and 5 deletions

View File

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

View File

@ -78,14 +78,15 @@ const string expand(const string &url)
const string strip(const string &url) const string strip(const string &url)
{ {
using replace_pair = std::pair<const std::regex, const std::string>; using replace_pair = std::pair<const std::regex, const std::string>;
using namespace std::regex_constants;
string newurl = url; string newurl = url;
const std::array<const replace_pair, 4> replace_array = const std::array<const replace_pair, 4> replace_array =
{{ {{
{ std::regex("[\\?&]utm_[^&]+"), "" }, { std::regex("[\\?&]utm_[^&]+", icase), "" }, // Google
{ std::regex("[\\?&]wtmc=[^&]+"), "" }, { std::regex("[\\?&]wtmc=[^&]+", icase), "" }, // Twitter
{ std::regex("[\\?&]__twitter_impression=[^&]+"), "" }, { std::regex("[\\?&]__twitter_impression=[^&]+", icase), "" }, // Twitter
{ std::regex("//amp\\."), "//" } { std::regex("//amp\\.", icase), "//" }, // AMP
}}; }};
for (const replace_pair &pair : replace_array) for (const replace_pair &pair : replace_array)