mirror of
https://github.com/xiaozhou233/JuiceAgent.git
synced 2026-12-05 13:05:53 +08:00
Feat: Config support ".xxx.xx" or "./xxx.xx"
This commit is contained in:
1 parent
8894a819f2
commit
b78839a8d4
1 file changed
+14
@@ -99,6 +99,20 @@ public:
|
||||
if constexpr (std::is_same_v<T, std::string>) {
|
||||
std::string s = val->as<std::string>();
|
||||
if (use_default_if_empty && s.empty()) return default_value;
|
||||
// Check if string starts with '.'
|
||||
if (s.starts_with('.')) {
|
||||
// remove '.'
|
||||
s.erase(0, 1);
|
||||
|
||||
// Check if string starts with '/'
|
||||
// MUST REMOVE '/', or it will cause path error (root directory)
|
||||
if (s.starts_with('/')) {
|
||||
s.erase(0, 1);
|
||||
}
|
||||
|
||||
// runtime_dir + s
|
||||
s = (std::filesystem::path(runtime_dir) / s).string();
|
||||
}
|
||||
return s;
|
||||
} else {
|
||||
return val->as<T>();
|
||||
|
||||
Reference in new issue
Block a user