Added URL stripping
This commit is contained in:
parent
db592a67ad
commit
b5d75af9fb
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required (VERSION 3.7)
|
cmake_minimum_required (VERSION 3.7)
|
||||||
project (expandurl-mastodon
|
project (expandurl-mastodon
|
||||||
VERSION 0.0.0
|
VERSION 0.0.2
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,24 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Expands shortened URLs
|
||||||
|
*
|
||||||
|
* @param url URL to expand
|
||||||
|
*
|
||||||
|
* @return Expanded URL
|
||||||
|
*/
|
||||||
const string expand(const string &url);
|
const string expand(const string &url);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Filters out tracking stuff
|
||||||
|
*
|
||||||
|
* Currently remoces all arguments beginning with `utm_`
|
||||||
|
*
|
||||||
|
* @param url URL to filter
|
||||||
|
*
|
||||||
|
* @return Filtered URL
|
||||||
|
*/
|
||||||
|
const string strip(const string &url);
|
||||||
|
|
||||||
#endif // EXPANDURL_MASTODON_HPP
|
#endif // EXPANDURL_MASTODON_HPP
|
||||||
|
|
|
@ -26,7 +26,8 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
curlpp::initialize();
|
curlpp::initialize();
|
||||||
|
|
||||||
cout << expand(argv[1]) << '\n';
|
// cout << expand(argv[1]) << '\n';
|
||||||
|
cout << strip(argv[1]) << '\n';
|
||||||
|
|
||||||
curlpp::Cleanup();
|
curlpp::Cleanup();
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <regex>
|
||||||
#include <curlpp/cURLpp.hpp>
|
#include <curlpp/cURLpp.hpp>
|
||||||
#include <curlpp/Options.hpp>
|
#include <curlpp/Options.hpp>
|
||||||
#include <curlpp/Infos.hpp>
|
#include <curlpp/Infos.hpp>
|
||||||
|
@ -52,3 +53,9 @@ const string expand(const string &url)
|
||||||
|
|
||||||
return curlpp::infos::EffectiveUrl::get(request);
|
return curlpp::infos::EffectiveUrl::get(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string strip(const string &url)
|
||||||
|
{
|
||||||
|
const std::regex re("[\\?&]utm_[^&]+");
|
||||||
|
return std::regex_replace(url, re, "");
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user