Fix #7516
This commit is contained in:
parent
720852f708
commit
cf29e9a9c5
|
@ -147,11 +147,16 @@ namespace Emby.Dlna.Server
|
|||
}
|
||||
}
|
||||
|
||||
private string GetFriendlyName()
|
||||
internal string GetFriendlyName()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_profile.FriendlyName))
|
||||
{
|
||||
return "Jellyfin - " + _serverName;
|
||||
return _serverName;
|
||||
}
|
||||
|
||||
if (!_profile.FriendlyName.Contains("${HostName}", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return _profile.FriendlyName;
|
||||
}
|
||||
|
||||
var characterList = new List<char>();
|
||||
|
@ -164,13 +169,18 @@ namespace Emby.Dlna.Server
|
|||
}
|
||||
}
|
||||
|
||||
var characters = characterList.ToArray();
|
||||
var serverName = string.Create(
|
||||
characterList.Count,
|
||||
characterList,
|
||||
(dest, source) =>
|
||||
{
|
||||
for (int i = 0; i < dest.Length; i++)
|
||||
{
|
||||
dest[i] = source[i];
|
||||
}
|
||||
});
|
||||
|
||||
var serverName = new string(characters);
|
||||
|
||||
var name = _profile.FriendlyName?.Replace("${HostName}", serverName, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
return name ?? string.Empty;
|
||||
return _profile.FriendlyName.Replace("${HostName}", serverName, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private void AppendIconList(StringBuilder builder)
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
using Emby.Dlna.Server;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Dlna.Server.Tests;
|
||||
|
||||
public class DescriptionXmlBuilderTests
|
||||
{
|
||||
[Fact]
|
||||
public void GetFriendlyName_EmptyProfile_ReturnsServerName()
|
||||
{
|
||||
const string ServerName = "Test Server Name";
|
||||
var builder = new DescriptionXmlBuilder(new DeviceProfile(), "serverUdn", "localhost", ServerName, string.Empty);
|
||||
Assert.Equal(ServerName, builder.GetFriendlyName());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFriendlyName_FriendlyName_ReturnsFriendlyName()
|
||||
{
|
||||
const string FriendlyName = "Friendly Neighborhood Test Server";
|
||||
var builder = new DescriptionXmlBuilder(
|
||||
new DeviceProfile()
|
||||
{
|
||||
FriendlyName = FriendlyName
|
||||
},
|
||||
"serverUdn",
|
||||
"localhost",
|
||||
"Test Server Name",
|
||||
string.Empty);
|
||||
Assert.Equal(FriendlyName, builder.GetFriendlyName());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFriendlyName_FriendlyNameInterpolation_ReturnsFriendlyName()
|
||||
{
|
||||
var builder = new DescriptionXmlBuilder(
|
||||
new DeviceProfile()
|
||||
{
|
||||
FriendlyName = "Friendly Neighborhood ${HostName}"
|
||||
},
|
||||
"serverUdn",
|
||||
"localhost",
|
||||
"Test Server Name",
|
||||
string.Empty);
|
||||
Assert.Equal("Friendly Neighborhood TestServerName", builder.GetFriendlyName());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user