From 8ce64ea784ca3345735cef7de9464583abd965dc Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Sat, 9 Sep 2023 09:38:03 -0500 Subject: [PATCH] refactor: make parsing sort-by more lenient --- include/util/enum.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/util/enum.hpp b/include/util/enum.hpp index a1cb6f6c..dcf0e45c 100644 --- a/include/util/enum.hpp +++ b/include/util/enum.hpp @@ -12,10 +12,16 @@ struct EnumParser { enum SORT_METHOD { ID, NAME, NUMBER, DEFAULT }; SORT_METHOD sortStringToEnum(const std::string& str) { + // Convert the input string to uppercase (make it lenient on config input) + std::string uppercaseStr; + for (char c : str) { + uppercaseStr += std::toupper(c); + } + static const std::map enumMap = { {"ID", ID}, {"NAME", NAME}, {"NUMBER", NUMBER}, {"DEFAULT", DEFAULT}}; - auto it = enumMap.find(str); + auto it = enumMap.find(uppercaseStr); if (it != enumMap.end()) { return it->second; } else {