static resources are mapped to full path instead of relative.

pull/6/head
kay.one 12 years ago
parent 43b4262e14
commit 3f44339381

@ -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>

@ -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, '|');
}
}
}

@ -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)

@ -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\");
}

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

Loading…
Cancel
Save