Rename function name

This commit is contained in:
TheRealLorenz
2023-03-25 17:33:01 +01:00
parent 473eb0982b
commit 63525ec956
5 changed files with 11 additions and 11 deletions

View File

@ -1,16 +1,16 @@
#include "util/rewrite_title.hpp"
#include "util/rewrite_string.hpp"
#include <spdlog/spdlog.h>
#include <regex>
namespace waybar::util {
std::string rewriteTitle(const std::string& title, const Json::Value& rules) {
std::string rewriteString(const std::string& value, const Json::Value& rules) {
if (!rules.isObject()) {
return title;
return value;
}
std::string res = title;
std::string res = value;
for (auto it = rules.begin(); it != rules.end(); ++it) {
if (it.key().isString() && it->isString()) {
@ -18,7 +18,7 @@ std::string rewriteTitle(const std::string& title, const Json::Value& rules) {
// malformated regexes will cause an exception.
// in this case, log error and try the next rule.
const std::regex rule{it.key().asString()};
if (std::regex_match(title, rule)) {
if (std::regex_match(value, rule)) {
res = std::regex_replace(res, rule, it->asString());
}
} catch (const std::regex_error& e) {