mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-26 09:47:39 +00:00
static resources are mapped to full path instead of relative.
This commit is contained in:
parent
43b4262e14
commit
3f44339381
5 changed files with 10 additions and 24 deletions
|
@ -75,7 +75,6 @@
|
||||||
<Compile Include="ClientSchemaTests\SchemaBuilderFixture.cs" />
|
<Compile Include="ClientSchemaTests\SchemaBuilderFixture.cs" />
|
||||||
<Compile Include="MappingTests\ReflectionExtensionFixture.cs" />
|
<Compile Include="MappingTests\ReflectionExtensionFixture.cs" />
|
||||||
<Compile Include="MappingTests\ResourceMappingFixture.cs" />
|
<Compile Include="MappingTests\ResourceMappingFixture.cs" />
|
||||||
<Compile Include="StaticResourceMapperFixture.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<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.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using NzbDrone.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Api.Frontend
|
namespace NzbDrone.Api.Frontend
|
||||||
{
|
{
|
||||||
public class StaticResourceMapper : IMapHttpRequestsToDisk
|
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" };
|
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)
|
public string Map(string resourceUrl)
|
||||||
{
|
{
|
||||||
var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar);
|
var path = resourceUrl.Replace('/', Path.DirectorySeparatorChar);
|
||||||
path = path.Trim(Path.DirectorySeparatorChar).ToLower();
|
path = path.Trim(Path.DirectorySeparatorChar).ToLower();
|
||||||
|
|
||||||
|
|
||||||
return Path.Combine("ui", path);
|
return Path.Combine(_environmentProvider.StartUpPath, "ui", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanHandle(string resourceUrl)
|
public bool CanHandle(string resourceUrl)
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace NzbDrone.Common.Test
|
||||||
[Test]
|
[Test]
|
||||||
public void AppDataDirectory_path_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; }
|
string SystemTemp { get; }
|
||||||
Version Version { get; }
|
Version Version { get; }
|
||||||
DateTime BuildDateTime { get; }
|
DateTime BuildDateTime { get; }
|
||||||
|
string StartUpPath { get; }
|
||||||
Version GetOsVersion();
|
Version GetOsVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue