Simplified logic
This commit is contained in:
@@ -1,18 +1,16 @@
|
||||
#include <glibmm/miscutils.h>
|
||||
|
||||
#include "util/hosts_check.hpp"
|
||||
|
||||
#include <glibmm/miscutils.h>
|
||||
#include <json/config.h>
|
||||
|
||||
namespace waybar::util {
|
||||
// replaces ``<>&"'`` with their encoded counterparts
|
||||
bool valid_host(const Json::Value& config) {
|
||||
if (config.isMember("hosts") && config["hosts"].isArray()) {
|
||||
auto hostname = Glib::get_host_name();
|
||||
for (const auto& host : config["hosts"]) {
|
||||
if (host.asString() == hostname) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
const auto hostname = Glib::get_host_name();
|
||||
|
||||
if (!std::ranges::any_of(config["hosts"].begin(), config["hosts"].end(),
|
||||
[&](const auto& h) { return h.asString() == hostname; }))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user