diff --git a/CMakeLists.txt b/CMakeLists.txt index 07fff5a..dd84396 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project (expandurl-mastodon - VERSION 0.3.0 + VERSION 0.3.1 LANGUAGES CXX ) diff --git a/src/url.cpp b/src/url.cpp index b5c0381..262b4bd 100644 --- a/src/url.cpp +++ b/src/url.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include @@ -75,6 +77,21 @@ const string expand(const string &url) const string strip(const string &url) { - const std::regex re("[\\?&]utm_[^&]+"); - return std::regex_replace(url, re, ""); + using replace_pair = std::pair; + string newurl = url; + + const std::array replace_array = + {{ + { std::regex("[\\?&]utm_[^&]+"), "" }, + { std::regex("[\\?&]wtmc=[^&]+"), "" }, + { std::regex("[\\?&]__twitter_impression=[^&]+"), "" }, + { std::regex("//amp\\."), "//" } + }}; + + for (const replace_pair &pair : replace_array) + { + newurl = std::regex_replace(newurl, pair.first, pair.second); + } + + return newurl; }