Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ namespace DotVVM.Framework.ResourceManagement
{
public class LocalResourceUrlManager : ILocalResourceUrlManager
{
private readonly ILogger logger;
private readonly ILogger? logger;
private readonly IResourceHashService hasher;
private readonly RouteBase resourceRoute;
private readonly DotvvmResourceRepository resources;
private readonly bool allowDebugFileResources;
private readonly bool requireResourceVersionHash;
private readonly bool allowResourceVersionHash;

public LocalResourceUrlManager(DotvvmConfiguration configuration, IResourceHashService hasher, ILogger<LocalResourceUrlManager> logger)
public LocalResourceUrlManager(DotvvmConfiguration configuration, IResourceHashService hasher, ILogger<LocalResourceUrlManager>? logger = null)
{
this.resourceRoute = new DotvvmRoute(
url: HostingConstants.ResourceRouteName + "-{name}/{fileName}",
Expand Down Expand Up @@ -89,7 +89,7 @@ protected virtual string GetVersionHash(ILocalResourceLocation location, IDotvvm
{
if (requireResourceVersionHash && GetVersionHash(location, context, name) != hash)
{ // check if the resource matches so that nobody can guess the url by chance
logger.LogInformation("Requested resource {name} with hash '{hash}' does not match the expected hash '{expectedHash}' and the request was rejected.", name, hash, GetVersionHash(location, context, name));
logger?.LogInformation("Requested resource {name} with hash '{hash}' does not match the expected hash '{expectedHash}' and the request was rejected.", name, hash, GetVersionHash(location, context, name));
return null;
}

Expand All @@ -99,7 +99,7 @@ protected virtual string GetVersionHash(ILocalResourceLocation location, IDotvvm
return TryLoadAlternativeFile(name, fileName, resource, context);
}

logger.LogInformation("Requested resource '{name}' not found.", name);
logger?.LogInformation("Requested resource '{name}' not found.", name);
return null;

}
Expand All @@ -120,7 +120,7 @@ private static bool IsAllowedFileName(string name)
{
if (!IsAllowedFileName(fileName))
{
logger.LogWarning("Requested additional file '{fileName}' for resource {resourceName} is not allowed.", fileName, name);
logger?.LogWarning("Requested additional file '{fileName}' for resource {resourceName} is not allowed.", fileName, name);
return null;
}

Expand Down