#include "pch.h" #include "Util.h" const std::vector Util::allowedHosts { "polygon.pizzaboxer.xyz", "polygondev.pizzaboxer.xyz", "polygonapi.pizzaboxer.xyz", "clientsettingsapi.pizzaboxer.xyz", "roblox.com", "www.roblox.com", "assetdelivery.roblox.com", "tadah.rocks", "www.tadah.rocks" }; const std::vector Util::allowedSchemes { "http", "https", "ftp" }; const std::vector Util::allowedEmbeddedSchemes { "javascript", "jscript", "res" }; std::map Util::parseArgs(std::string args) { std::map map; std::string::size_type key_pos = 0; std::string::size_type key_end; std::string::size_type val_pos; std::string::size_type val_end; while ((key_end = args.find(' ', key_pos)) != std::string::npos) { if ((val_pos = args.find_first_not_of(" -", key_end)) == std::string::npos) break; val_end = args.find(" -", val_pos); map.emplace(args.substr(key_pos, key_end - key_pos), args.substr(val_pos, val_end - val_pos)); key_pos = val_end; if (key_pos != std::string::npos) ++key_pos; } return map; } // https://stackoverflow.com/questions/48212992/how-to-find-out-if-there-is-any-non-ascii-character-in-a-string-with-a-file-path bool Util::isASCII(const std::string& s) { return !std::any_of(s.begin(), s.end(), [](char c) { return static_cast(c) > 127; }); } // https://stackoverflow.com/questions/313970/how-to-convert-an-instance-of-stdstring-to-lower-case std::string Util::toLower(std::string s) { std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return std::tolower(c); }); return s; }