Skip to content

Commit 4b125d9

Browse files
Only match requests for the configured root path
1 parent 6d5d771 commit 4b125d9

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/Umbraco.StorageProviders.AzureBlob/Imaging/AzureBlobFileSystemImageProvider.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ public class AzureBlobFileSystemImageProvider : IImageProvider
2020
private string _rootPath;
2121
private readonly FormatUtilities _formatUtilities;
2222

23+
/// <summary>
24+
/// A match function used by the resolver to identify itself as the correct resolver to use.
25+
/// </summary>
26+
private Func<HttpContext, bool>? _match;
27+
2328
/// <summary>
2429
/// Initializes a new instance of the <see cref="AzureBlobFileSystemImageProvider" /> class.
2530
/// </summary>
@@ -68,8 +73,7 @@ public bool IsValidRequest(HttpContext context)
6873
{
6974
if (context == null) throw new ArgumentNullException(nameof(context));
7075

71-
return context.Request.Path.StartsWithSegments(_rootPath, StringComparison.InvariantCultureIgnoreCase)
72-
&& _formatUtilities.GetExtensionFromUri(context.Request.GetDisplayUrl()) != null;
76+
return _formatUtilities.GetExtensionFromUri(context.Request.GetDisplayUrl()) != null;
7377
}
7478

7579
/// <inheritdoc />
@@ -95,8 +99,19 @@ public bool IsValidRequest(HttpContext context)
9599
/// <inheritdoc />
96100
public ProcessingBehavior ProcessingBehavior => ProcessingBehavior.CommandOnly;
97101

98-
/// <inheritdoc />
99-
public Func<HttpContext, bool> Match { get; set; } = _ => true;
102+
/// <inheritdoc/>
103+
public Func<HttpContext, bool> Match
104+
{
105+
get => this._match ?? IsMatch;
106+
set => this._match = value;
107+
}
108+
109+
private bool IsMatch(HttpContext context)
110+
{
111+
if (context == null) throw new ArgumentNullException(nameof(context));
112+
113+
return context.Request.Path.StartsWithSegments(_rootPath, StringComparison.InvariantCultureIgnoreCase);
114+
}
100115

101116
private void OptionsOnChange(AzureBlobFileSystemOptions options, string name, IHostingEnvironment hostingEnvironment)
102117
{

0 commit comments

Comments
 (0)