mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-05-09 05:22:09 +02:00
Fixed: Caching for dynamically loaded JS files Fixed: Incorrect caching of initialize.js (cherry picked from commit f0cb5b81f140c67fa84162e094cc4e0f3476f5da)
48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using System.IO;
|
|
using NLog;
|
|
using NzbDrone.Common.Disk;
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
namespace Prowlarr.Http.Frontend.Mappers
|
|
{
|
|
public class StaticResourceMapper : StaticResourceMapperBase
|
|
{
|
|
private readonly IAppFolderInfo _appFolderInfo;
|
|
private readonly IConfigFileProvider _configFileProvider;
|
|
|
|
public StaticResourceMapper(IAppFolderInfo appFolderInfo, IDiskProvider diskProvider, IConfigFileProvider configFileProvider, Logger logger)
|
|
: base(diskProvider, logger)
|
|
{
|
|
_appFolderInfo = appFolderInfo;
|
|
_configFileProvider = configFileProvider;
|
|
}
|
|
|
|
public override string Map(string resourceUrl)
|
|
{
|
|
var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar);
|
|
path = path.Trim(Path.DirectorySeparatorChar);
|
|
|
|
return Path.Combine(_appFolderInfo.StartUpFolder, _configFileProvider.UiFolder, path);
|
|
}
|
|
|
|
public override bool CanHandle(string resourceUrl)
|
|
{
|
|
resourceUrl = resourceUrl.ToLowerInvariant();
|
|
|
|
if (resourceUrl.StartsWith("/content/images/icons/manifest") ||
|
|
resourceUrl.StartsWith("/content/images/icons/browserconfig"))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return resourceUrl.StartsWith("/content") ||
|
|
resourceUrl.EndsWith(".js") ||
|
|
resourceUrl.EndsWith(".map") ||
|
|
resourceUrl.EndsWith(".css") ||
|
|
(resourceUrl.EndsWith(".ico") && !resourceUrl.Equals("/favicon.ico")) ||
|
|
resourceUrl.EndsWith(".swf") ||
|
|
resourceUrl.EndsWith("oauth.html");
|
|
}
|
|
}
|
|
}
|