diff --git a/src/Geta.NotFoundHandler/Core/Providers/RegexRedirects/RegexRedirectNotFoundHandler.cs b/src/Geta.NotFoundHandler/Core/Providers/RegexRedirects/RegexRedirectNotFoundHandler.cs index 46bd004a..e4f91e6d 100644 --- a/src/Geta.NotFoundHandler/Core/Providers/RegexRedirects/RegexRedirectNotFoundHandler.cs +++ b/src/Geta.NotFoundHandler/Core/Providers/RegexRedirects/RegexRedirectNotFoundHandler.cs @@ -1,10 +1,12 @@ -// Copyright (c) Geta Digital. All rights reserved. +// Copyright (c) Geta Digital. All rights reserved. // Licensed under Apache-2.0. See the LICENSE file in the project root for more information using System.Text.RegularExpressions; using Geta.NotFoundHandler.Core.Redirects; using Geta.NotFoundHandler.Data; +using Geta.NotFoundHandler.Infrastructure.Configuration; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; namespace Geta.NotFoundHandler.Core.Providers.RegexRedirects; @@ -12,11 +14,16 @@ public class RegexRedirectNotFoundHandler : INotFoundHandler { private readonly IRegexRedirectLoader _regexRedirectLoader; private readonly ILogger _logger; + private readonly NotFoundHandlerOptions _options; - public RegexRedirectNotFoundHandler(IRegexRedirectLoader regexRedirectLoader, ILogger logger) + public RegexRedirectNotFoundHandler( + IRegexRedirectLoader regexRedirectLoader, + ILogger logger, + IOptions options) { _regexRedirectLoader = regexRedirectLoader; _logger = logger; + _options = options.Value; } public RewriteResult RewriteUrl(string url) @@ -31,7 +38,7 @@ public RewriteResult RewriteUrl(string url) if (match.Success) { var newUrl = match.Result(redirect.NewUrlFormat); - return new RewriteResult(newUrl, RedirectType.Temporary); + return new RewriteResult(newUrl, _options.DefaultRedirectType); } } catch (RegexMatchTimeoutException e)