mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
static resources are mapped to full path instead of relative.
This commit is contained in:
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 @@ public void normalize_path_exception_null()
|
||||
[Test]
|
||||
public void AppDataDirectory_path_test()
|
||||
{
|
||||
GetEnvironmentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\App_Data\");
|
||||
GetEnvironmentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\");
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,6 +12,7 @@ public interface IEnvironmentProvider
|
||||
string SystemTemp { get; }
|
||||
Version Version { get; }
|
||||
DateTime BuildDateTime { get; }
|
||||
string StartUpPath { get; }
|
||||
Version GetOsVersion();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user