Skip to content

Commit

Permalink
Fixed: (CardigannBase) Remedy for casting strings to booleans
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameisbogdan committed Feb 19, 2023
1 parent caa8bb0 commit 34c560f
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,12 @@ protected string HandleJsonSelector(SelectorBlock selector, JToken parentObj, Di
}
else if (setting.Type == "checkbox")
{
variables[name] = ((bool)value) ? ".True" : null;
if (value is string stringValue && bool.TryParse(stringValue, out var result))
{
value = result;
}

variables[name] = (bool)value ? ".True" : null;
}
else if (setting.Type == "select")
{
Expand Down Expand Up @@ -328,12 +333,12 @@ protected string HandleJsonSelector(SelectorBlock selector, JToken parentObj, Di
}
else
{
throw new NotSupportedException();
throw new NotSupportedException($"Type {setting.Type} is not supported.");
}

if (setting.Type != "password" && setting.Name != "apikey" && setting.Name != "rsskey" && indexerLogging)
if (setting.Type != "password" && setting.Name != "apikey" && setting.Name != "rsskey" && indexerLogging && variables.ContainsKey(name))
{
_logger.Debug($"Setting {setting.Name} to {variables[name]}");
_logger.Debug($"Setting {setting.Name} to {variables[name].ToJson()}");
}
}

Expand Down

0 comments on commit 34c560f

Please sign in to comment.