Simplify BaseUrlRedirectionMiddleware
This commit is contained in:
parent
01e8ff8ddf
commit
9595aa258e
|
@ -50,18 +50,15 @@ namespace Jellyfin.Server.Middleware
|
||||||
var startsWithBaseUrl = localPath.StartsWith(baseUrlPrefix, StringComparison.OrdinalIgnoreCase);
|
var startsWithBaseUrl = localPath.StartsWith(baseUrlPrefix, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
if (!startsWithBaseUrl
|
if (!startsWithBaseUrl
|
||||||
&& localPath.EndsWith("/health", StringComparison.OrdinalIgnoreCase))
|
&& (localPath.Equals("/health", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| localPath.Equals("/health/", StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Redirecting /health check");
|
_logger.LogDebug("Redirecting /health check");
|
||||||
httpContext.Response.Redirect(baseUrlPrefix + "/health");
|
httpContext.Response.Redirect(baseUrlPrefix + "/health");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.Equals(localPath, baseUrlPrefix + "/", StringComparison.OrdinalIgnoreCase)
|
if (!startsWithBaseUrl)
|
||||||
|| string.Equals(localPath, baseUrlPrefix, StringComparison.OrdinalIgnoreCase)
|
|
||||||
|| string.Equals(localPath, "/", StringComparison.OrdinalIgnoreCase)
|
|
||||||
|| string.IsNullOrEmpty(localPath)
|
|
||||||
|| !startsWithBaseUrl)
|
|
||||||
{
|
{
|
||||||
// Always redirect back to the default path if the base prefix is invalid or missing
|
// Always redirect back to the default path if the base prefix is invalid or missing
|
||||||
_logger.LogDebug("Normalizing an URL at {LocalPath}", localPath);
|
_logger.LogDebug("Normalizing an URL at {LocalPath}", localPath);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user