Radarr/NzbDrone.Api/Frontend/StaticResourceMapper.cs

29 lines
806 B
C#
Raw Normal View History

using System.IO;
2013-05-18 01:18:02 +00:00
using System.Linq;
namespace NzbDrone.Api.Frontend
{
public class StaticResourceMapper : IMapHttpRequestsToDisk
{
2013-05-18 01:18:02 +00:00
private static readonly string[] Extensions = new[] { ".css", ".js", ".html", ".htm", ".jpg", ".jpeg", ".icon", ".gif", ".png", ".woff", ".ttf" };
public string Map(string resourceUrl)
{
var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar);
path = path.Trim(Path.DirectorySeparatorChar).ToLower();
2013-05-03 05:42:18 +00:00
return Path.Combine("ui", path);
}
2013-05-18 01:18:02 +00:00
public bool CanHandle(string resourceUrl)
{
if (string.IsNullOrWhiteSpace(resourceUrl))
{
return false;
}
return Extensions.Any(resourceUrl.EndsWith);
}
}
}