Append base URL if the published server URL override omits it. Fleshed out unit tests to cover that and https->http reverse proxy scenario(s).
This commit is contained in:
@@ -555,11 +555,6 @@ public class MediaInfoHelper
|
||||
return;
|
||||
}
|
||||
|
||||
if (mediaSource.Protocol != MediaProtocol.Http)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var baseUrl = _serverConfigurationManager.GetNetworkConfiguration().BaseUrl;
|
||||
var publishedPath = GetPublishedLiveStreamPath(_appHost.GetSmartApiUrl(request), mediaSource.Path, mediaSource.Protocol, baseUrl);
|
||||
|
||||
@@ -613,6 +608,20 @@ public class MediaInfoHelper
|
||||
return null;
|
||||
}
|
||||
|
||||
return smartApiUrl.TrimEnd('/') + relativePath;
|
||||
var prefix = smartApiUrl.TrimEnd('/');
|
||||
if (!string.IsNullOrEmpty(baseUrl))
|
||||
{
|
||||
var includesBaseUrl = Uri.TryCreate(prefix, UriKind.Absolute, out var publishedUri)
|
||||
&& Uri.UnescapeDataString(publishedUri.AbsolutePath)
|
||||
.TrimEnd('/')
|
||||
.EndsWith(baseUrl, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (!includesBaseUrl)
|
||||
{
|
||||
prefix += baseUrl;
|
||||
}
|
||||
}
|
||||
|
||||
return prefix + relativePath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,6 +433,48 @@ namespace Jellyfin.Api.Tests.Helpers
|
||||
MediaProtocol.Http,
|
||||
"",
|
||||
"https://media.example.com" + LiveStreamFilesPath)]
|
||||
[InlineData(
|
||||
"https://media.example.com",
|
||||
"https://172.19.0.3:8920" + LiveStreamFilesPath,
|
||||
MediaProtocol.Http,
|
||||
"",
|
||||
"https://media.example.com" + LiveStreamFilesPath)]
|
||||
[InlineData(
|
||||
"https://media.example.com",
|
||||
"http://192.168.1.10:8096" + LiveStreamFilesPath,
|
||||
MediaProtocol.Http,
|
||||
"",
|
||||
"https://media.example.com" + LiveStreamFilesPath)]
|
||||
[InlineData(
|
||||
"https://media.example.com:8920",
|
||||
"http://172.19.0.3:8096" + LiveStreamFilesPath,
|
||||
MediaProtocol.Http,
|
||||
"",
|
||||
"https://media.example.com:8920" + LiveStreamFilesPath)]
|
||||
[InlineData(
|
||||
"https://media.example.com",
|
||||
"http://172.19.0.3:8096/jellyfin" + LiveStreamFilesPath,
|
||||
MediaProtocol.Http,
|
||||
"/jellyfin",
|
||||
"https://media.example.com/jellyfin" + LiveStreamFilesPath)]
|
||||
[InlineData(
|
||||
"https://jellyfin",
|
||||
"http://172.19.0.3:8096/jellyfin" + LiveStreamFilesPath,
|
||||
MediaProtocol.Http,
|
||||
"/jellyfin",
|
||||
"https://jellyfin/jellyfin" + LiveStreamFilesPath)]
|
||||
[InlineData(
|
||||
"https://media.example.com/jellyfin",
|
||||
"http://172.19.0.3:8096/jellyfin" + LiveStreamFilesPath,
|
||||
MediaProtocol.Http,
|
||||
"/jellyfin",
|
||||
"https://media.example.com/jellyfin" + LiveStreamFilesPath)]
|
||||
[InlineData(
|
||||
"https://media.example.com/jellyfin/",
|
||||
"http://172.19.0.3:8096/jellyfin" + LiveStreamFilesPath,
|
||||
MediaProtocol.Http,
|
||||
"/jellyfin",
|
||||
"https://media.example.com/jellyfin" + LiveStreamFilesPath)]
|
||||
[InlineData(
|
||||
"https://media.example.com",
|
||||
"http://172.19.0.3:8096/jellyfin2" + LiveStreamFilesPath,
|
||||
|
||||
Reference in New Issue
Block a user