refactor: Fix analysis warnings

pull/201/head
Robert Dailey 10 months ago
parent ade5ee72b2
commit 1d7abb3977

@ -37,7 +37,7 @@ public record UpdatedQualityProfile
// The `qualityprofile` API will still validate `cutoff` even when `upgradeAllowed` is set to `false`. // The `qualityprofile` API will still validate `cutoff` even when `upgradeAllowed` is set to `false`.
// Because of this, we cannot set cutoff to null. We pick the first available if the user didn't specify one. // Because of this, we cannot set cutoff to null. We pick the first available if the user didn't specify one.
var cutoff = config.UpgradeAllowed is true var cutoff = config.UpgradeAllowed
? UpdatedQualities.Items.FindCutoff(config.UpgradeUntilQuality) ? UpdatedQualities.Items.FindCutoff(config.UpgradeUntilQuality)
: UpdatedQualities.Items.First().Id; : UpdatedQualities.Items.First().Id;

@ -1,9 +1,8 @@
@page "/" @page "/"
@using Microsoft.AspNetCore.Mvc.TagHelpers
@namespace Recyclarr.Gui.Pages @namespace Recyclarr.Gui.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{ @{
Layout = "_Layout"; Layout = "_Layout";
} }
<component type="typeof(App)" render-mode="ServerPrerendered" /> <component type="typeof(App)" render-mode="ServerPrerendered" />

@ -1,5 +1,4 @@
@using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Mvc.TagHelpers
@namespace Recyclarr.Gui.Pages @namespace Recyclarr.Gui.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@ -3,23 +3,26 @@ using Flurl.Http;
namespace Recyclarr.TrashLib.Http; namespace Recyclarr.TrashLib.Http;
public static class FlurlExtensions public static partial class FlurlExtensions
{ {
public static string SanitizedExceptionMessage(this FlurlHttpException exception) public static string SanitizedExceptionMessage(this FlurlHttpException exception)
{ {
// Replace full URLs // Replace full URLs
const string urlExpression = var result = UrlRegex().Replace(exception.Message, Sanitize);
@"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}(\:[0-9]+)?\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)";
var result = Regex.Replace(exception.Message, urlExpression, Sanitize);
// There are sometimes parenthetical parts of the message that contain the host but are not // There are sometimes parenthetical parts of the message that contain the host but are not
// detected as true URLs. Just strip those out completely. // detected as true URLs. Just strip those out completely.
const string hostExpression = @"\([-a-zA-Z0-9@:%._+~#=]{1,256}(?:\:[0-9]+)\)"; return HostRegex().Replace(result, "");
return Regex.Replace(result, hostExpression, "");
} }
private static string Sanitize(Match match) private static string Sanitize(Match match)
{ {
return FlurlLogging.SanitizeUrl(match.Value).ToString(); return FlurlLogging.SanitizeUrl(match.Value).ToString() ?? match.Value;
} }
[GeneratedRegex(@"\([-a-zA-Z0-9@:%._+~#=]{1,256}(?::[0-9]+)?\)")]
private static partial Regex HostRegex();
[GeneratedRegex(@"https?://(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}(:[0-9]+)?\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)")]
private static partial Regex UrlRegex();
} }

Loading…
Cancel
Save