Merge pull request #6404 from crobibero/redirect-base-url

Fix redirect logic if request path is exactly the base url
This commit is contained in:
Bond-009 2021-08-08 14:53:19 +02:00 committed by GitHub
commit ab88e30cfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,9 +58,12 @@ namespace Jellyfin.Server.Middleware
return;
}
if (!startsWithBaseUrl)
if (!startsWithBaseUrl
|| localPath.Length == baseUrlPrefix.Length
// Local path is /baseUrl/
|| (localPath.Length == baseUrlPrefix.Length + 1 && localPath[^1] == '/'))
{
// 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, missing, or is the full path.
_logger.LogDebug("Normalizing an URL at {LocalPath}", localPath);
httpContext.Response.Redirect(baseUrlPrefix + "/" + _configuration[ConfigurationExtensions.DefaultRedirectKey]);
return;