Browse Source

Middleware fixed

pull/1/head
Sebastian 10 years ago
parent
commit
06c9d57c1a
  1. 16
      src/Squidex/Pipeline/SingleUrlsMiddleware.cs

16
src/Squidex/Pipeline/SingleUrlsMiddleware.cs

@ -30,20 +30,12 @@ namespace Squidex.Pipeline
var currentUrl = string.Concat(context.Request.Scheme, "://", context.Request.Host, context.Request.Path); var currentUrl = string.Concat(context.Request.Scheme, "://", context.Request.Host, context.Request.Path);
var hostName = context.Request.Host.ToString().ToLowerInvariant(); var hostName = context.Request.Host.ToString().ToLowerInvariant();
if (hostName.StartsWith("www")) if (hostName.StartsWith("www."))
{ {
hostName = hostName.Substring(3); hostName = hostName.Substring(4);
} }
var requestPath = context.Request.Path.ToString(); var newUrl = string.Concat("https://", hostName, context.Request.Path);
if (!requestPath.EndsWith("/") &&
!requestPath.Contains("."))
{
requestPath = requestPath + "/";
}
var newUrl = string.Concat("https://", hostName, requestPath);
if (!string.Equals(newUrl, currentUrl, StringComparison.OrdinalIgnoreCase)) if (!string.Equals(newUrl, currentUrl, StringComparison.OrdinalIgnoreCase))
{ {

Loading…
Cancel
Save