Apply template text to switch cases in Cardigann

pull/1672/head
Bogdan 1 year ago
parent 4561859c2b
commit 46d930e903

@ -169,7 +169,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
{ {
if (selection.Matches(@case.Key) || QuerySelector(selection, @case.Key) != null) if (selection.Matches(@case.Key) || QuerySelector(selection, @case.Key) != null)
{ {
value = @case.Value; value = ApplyGoTemplateText(@case.Value, variables);
break; break;
} }
} }
@ -178,7 +178,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
{ {
if (required) if (required)
{ {
throw new Exception(string.Format("None of the case selectors \"{0}\" matched {1}", string.Join(",", selector.Case), selection.ToHtmlPretty())); throw new Exception($"None of the case selectors \"{string.Join(",", selector.Case)}\" matched {selection.ToHtmlPretty()}");
} }
return null; return null;
@ -249,11 +249,11 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
if (selector.Case != null) if (selector.Case != null)
{ {
foreach (var jcase in selector.Case) foreach (var @case in selector.Case)
{ {
if (value.Equals(jcase.Key) || jcase.Key.Equals("*")) if ((value != null && value.Equals(@case.Key)) || @case.Key.Equals("*"))
{ {
value = jcase.Value; value = ApplyGoTemplateText(@case.Value, variables);
break; break;
} }
} }
@ -262,7 +262,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
{ {
if (required) if (required)
{ {
throw new Exception(string.Format("None of the case selectors \"{0}\" matched {1}", string.Join(",", selector.Case), parentObj.ToString())); throw new Exception($"None of the case selectors \"{string.Join(",", selector.Case)}\" matched {parentObj}");
} }
return null; return null;

Loading…
Cancel
Save