1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-25 17:27:18 +00:00

static resources are mapped to full path instead of relative.

This commit is contained in:
kay.one 2013-05-19 18:19:10 -07:00
parent 43b4262e14
commit 3f44339381
5 changed files with 10 additions and 24 deletions

View file

@ -75,7 +75,6 @@
<Compile Include="ClientSchemaTests\SchemaBuilderFixture.cs" />
<Compile Include="MappingTests\ReflectionExtensionFixture.cs" />
<Compile Include="MappingTests\ResourceMappingFixture.cs" />
<Compile Include="StaticResourceMapperFixture.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>

View file

@ -1,21 +0,0 @@
using System.IO;
using NUnit.Framework;
using NzbDrone.Api.Frontend;
using NzbDrone.Test.Common;
namespace NzbDrone.Api.Test
{
[TestFixture]
public class StaticResourceMapperFixture : TestBase<StaticResourceMapper>
{
[TestCase("/app.js", Result = "ui|app.js")]
[TestCase("/series/app.js", Result = "ui|series|app.js")]
[TestCase("series/app.js", Result = "ui|series|app.js")]
[TestCase("Series/App.js", Result = "ui|series|app.js")]
public string should_map_paths(string path)
{
return Subject.Map(path).Replace(Path.DirectorySeparatorChar, '|');
}
}
}

View file

@ -1,19 +1,26 @@
using System.IO;
using System.Linq;
using NzbDrone.Common;
namespace NzbDrone.Api.Frontend
{
public class StaticResourceMapper : IMapHttpRequestsToDisk
{
private readonly IEnvironmentProvider _environmentProvider;
private static readonly string[] Extensions = new[] { ".css", ".js", ".html", ".htm", ".jpg", ".jpeg", ".icon", ".gif", ".png", ".woff", ".ttf" };
public StaticResourceMapper(IEnvironmentProvider environmentProvider)
{
_environmentProvider = environmentProvider;
}
public string Map(string resourceUrl)
{
var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar);
path = path.Trim(Path.DirectorySeparatorChar).ToLower();
return Path.Combine("ui", path);
return Path.Combine(_environmentProvider.StartUpPath, "ui", path);
}
public bool CanHandle(string resourceUrl)

View file

@ -73,7 +73,7 @@ namespace NzbDrone.Common.Test
[Test]
public void AppDataDirectory_path_test()
{
GetEnvironmentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\App_Data\");
GetEnvironmentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\");
}

View file

@ -12,6 +12,7 @@ namespace NzbDrone.Common
string SystemTemp { get; }
Version Version { get; }
DateTime BuildDateTime { get; }
string StartUpPath { get; }
Version GetOsVersion();
}