Fixed up StaticResourceProvider

This commit is contained in:
Mark McDowall 2013-05-17 18:18:02 -07:00
parent 92d913e4ac
commit 1edb1d211b
4 changed files with 33 additions and 44 deletions

View file

@ -1,9 +1,12 @@
using System.IO;
using System.Linq;
namespace NzbDrone.Api.Frontend
{
public class StaticResourceMapper : IMapHttpRequestsToDisk
{
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);
@ -13,6 +16,14 @@ namespace NzbDrone.Api.Frontend
return Path.Combine("ui", path);
}
public RequestType IHandle { get { return RequestType.StaticResources; } }
public bool CanHandle(string resourceUrl)
{
if (string.IsNullOrWhiteSpace(resourceUrl))
{
return false;
}
return Extensions.Any(resourceUrl.EndsWith);
}
}
}