Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves #385. #386

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Articulate/Routing/TagsOrCategoryPathRouteConstraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ private class UrlNames

private readonly List<UrlNames> _urlNames;

private const string DetectDomainAbsoluteUrl = "localhost";

public TagsOrCategoryPathRouteConstraint(ContentUrls contentUrls, IEnumerable<IPublishedContent> itemsForRoute)
{
if (itemsForRoute == null) throw new ArgumentNullException(nameof(itemsForRoute));
Expand All @@ -38,7 +40,7 @@ public TagsOrCategoryPathRouteConstraint(ContentUrls contentUrls, IEnumerable<IP
foreach (var url in allUrls)
{
//if there is a double slash, it will have a domain
if (url.Contains("//"))
if (url.InvariantContains(DetectDomainAbsoluteUrl))
{
var uri = new Uri(url, UriKind.Absolute);
urlNames.Add(new UrlNames
Expand Down Expand Up @@ -78,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.Host.InvariantEquals("localhost")
: !httpContext.Request.Url.AbsoluteUri.InvariantContains(DetectDomainAbsoluteUrl)
? _urlNames.FirstOrDefault(x => x.Host == string.Empty)
: _urlNames.FirstOrDefault(x => x.Host.InvariantEquals(httpContext.Request.Url.Host));
}
Expand All @@ -90,4 +92,4 @@ public bool Match(HttpContextBase httpContext, Route route, string parameterName
return currentAction.InvariantEquals(urlNames.TagsUrlName) || currentAction.InvariantEquals(urlNames.CategoryUrlName);
}
}
}
}