From af38df57457535b5f939f6a61a2ea53c4a8eafed Mon Sep 17 00:00:00 2001 From: smackintosh Date: Tue, 24 May 2022 10:06:42 +0100 Subject: [PATCH 1/5] Resolves #385. --- .../Routing/TagsOrCategoryPathRouteConstraint.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs b/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs index c0c90c43..9ccf779d 100644 --- a/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs +++ b/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs @@ -25,6 +25,8 @@ private class UrlNames private readonly List _urlNames; + private const string DetectDomainAbsoluteUrl = "//"; + public TagsOrCategoryPathRouteConstraint(ContentUrls contentUrls, IEnumerable itemsForRoute) { if (itemsForRoute == null) throw new ArgumentNullException(nameof(itemsForRoute)); @@ -38,7 +40,7 @@ public TagsOrCategoryPathRouteConstraint(ContentUrls contentUrls, IEnumerable x.Host == string.Empty) - : _urlNames.FirstOrDefault(x => x.Host.InvariantEquals(httpContext.Request.Url.Host)); + ? _urlNames.FirstOrDefault() //cannot be determined + : !httpContext.Request.Url.AbsoluteUri.Contains(DetectDomainAbsoluteUrl) + ? _urlNames.FirstOrDefault(x => x.Host == string.Empty) + : _urlNames.FirstOrDefault(x => x.Host.InvariantEquals(httpContext.Request.Url.Host)); } if (urlNames == null) return false; @@ -90,4 +92,4 @@ public bool Match(HttpContextBase httpContext, Route route, string parameterName return currentAction.InvariantEquals(urlNames.TagsUrlName) || currentAction.InvariantEquals(urlNames.CategoryUrlName); } } -} \ No newline at end of file +} From 441f3f5946a88f96239044a33a0a34014df626e1 Mon Sep 17 00:00:00 2001 From: smackintosh Date: Tue, 24 May 2022 10:10:15 +0100 Subject: [PATCH 2/5] Resolves #385. Fix alignment. --- .../Routing/TagsOrCategoryPathRouteConstraint.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs b/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs index 9ccf779d..d72a48f1 100644 --- a/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs +++ b/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs @@ -79,10 +79,10 @@ public bool Match(HttpContextBase httpContext, Route route, string parameterName else { urlNames = httpContext.Request.Url == null - ? _urlNames.FirstOrDefault() //cannot be determined - : !httpContext.Request.Url.AbsoluteUri.Contains(DetectDomainAbsoluteUrl) - ? _urlNames.FirstOrDefault(x => x.Host == string.Empty) - : _urlNames.FirstOrDefault(x => x.Host.InvariantEquals(httpContext.Request.Url.Host)); + ? _urlNames.FirstOrDefault() //cannot be determined + : !httpContext.Request.Url.AbsoluteUri.Contains(DetectDomainAbsoluteUrl) + ? _urlNames.FirstOrDefault(x => x.Host == string.Empty) + : _urlNames.FirstOrDefault(x => x.Host.InvariantEquals(httpContext.Request.Url.Host)); } if (urlNames == null) return false; From 3993a99f8db8e4e0dd5fbf22116deb4bf7353ef1 Mon Sep 17 00:00:00 2001 From: smackintosh Date: Thu, 9 Jun 2022 09:08:18 +0100 Subject: [PATCH 3/5] Resolves #385. Changed comparison for "//" to "localhost", this also resolves the issue. --- src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs b/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs index d72a48f1..5634f36e 100644 --- a/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs +++ b/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs @@ -25,7 +25,7 @@ private class UrlNames private readonly List _urlNames; - private const string DetectDomainAbsoluteUrl = "//"; + private const string DetectDomainAbsoluteUrl = "localhost"; public TagsOrCategoryPathRouteConstraint(ContentUrls contentUrls, IEnumerable itemsForRoute) { @@ -40,7 +40,7 @@ public TagsOrCategoryPathRouteConstraint(ContentUrls contentUrls, IEnumerable x.Host == string.Empty) : _urlNames.FirstOrDefault(x => x.Host.InvariantEquals(httpContext.Request.Url.Host)); } From dada4e7d889faedc503a7d866c48d9aac5d5c807 Mon Sep 17 00:00:00 2001 From: smackintosh Date: Thu, 9 Jun 2022 09:11:06 +0100 Subject: [PATCH 4/5] Resolves #385. Changed comparison for "//" to "localhost", this also resolves the issue. --- src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs b/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs index 5634f36e..8dd6abfa 100644 --- a/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs +++ b/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs @@ -80,7 +80,7 @@ public bool Match(HttpContextBase httpContext, Route route, string parameterName { urlNames = httpContext.Request.Url == null ? _urlNames.FirstOrDefault() //cannot be determined - : !httpContext.Request.Url.AbsoluteUri.Contains(DetectDomainAbsoluteUrl) + : !httpContext.Request.Url.AbsoluteUri.InvariantContains(DetectDomainAbsoluteUrl) ? _urlNames.FirstOrDefault(x => x.Host == string.Empty) : _urlNames.FirstOrDefault(x => x.Host.InvariantEquals(httpContext.Request.Url.Host)); } From dc468f59f1f7cc2c1964ae23ab2403fb671f4f4a Mon Sep 17 00:00:00 2001 From: smackintosh Date: Thu, 9 Jun 2022 09:12:49 +0100 Subject: [PATCH 5/5] Resolves #385. Changed comparison for "//" to "localhost", this also resolves the issue. Fixed alignment. --- src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs b/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs index 8dd6abfa..c0e02e4a 100644 --- a/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs +++ b/src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs @@ -80,7 +80,7 @@ public bool Match(HttpContextBase httpContext, Route route, string parameterName { urlNames = httpContext.Request.Url == null ? _urlNames.FirstOrDefault() //cannot be determined - : !httpContext.Request.Url.AbsoluteUri.InvariantContains(DetectDomainAbsoluteUrl) + : !httpContext.Request.Url.AbsoluteUri.InvariantContains(DetectDomainAbsoluteUrl) ? _urlNames.FirstOrDefault(x => x.Host == string.Empty) : _urlNames.FirstOrDefault(x => x.Host.InvariantEquals(httpContext.Request.Url.Host)); }