Skip to content

Commit

Permalink
Fixes #267, absolute paths returned from UrlResolver cause exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
NightOwl888 committed Feb 9, 2014
1 parent e625905 commit 0c8a2f1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/MvcSiteMapProvider/MvcSiteMapProvider/SiteMapNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,16 @@ public override string Url
{
return string.Empty;
}
if (!String.IsNullOrEmpty(this.ResolvedUrl))
if (!string.IsNullOrEmpty(this.ResolvedUrl))
{
return this.ResolvedUrl;
}
// Only resolve the url if an absolute url is not already set
if (this.HasAbsoluteUrl())
// IMPORTANT: Must not call HasAbsoluteUrl here because that method calls this property.
var unresolved = this.UnresolvedUrl;
if (this.urlPath.IsAbsoluteUrl(unresolved))
{
return this.UnresolvedUrl;
return unresolved;
}
return GetResolvedUrl();
}
Expand Down Expand Up @@ -360,7 +362,7 @@ public override string Url
/// </summary>
public override void ResolveUrl()
{
if (this.CacheResolvedUrl && String.IsNullOrEmpty(this.UnresolvedUrl) && this.preservedRouteParameters.Count == 0)
if (this.CacheResolvedUrl && string.IsNullOrEmpty(this.UnresolvedUrl) && this.preservedRouteParameters.Count == 0)
{
this.resolvedUrl = this.GetResolvedUrl();
}
Expand All @@ -381,7 +383,7 @@ protected string GetResolvedUrl()
/// <returns></returns>
public override bool HasAbsoluteUrl()
{
return urlPath.IsAbsoluteUrl(this.url);
return this.urlPath.IsAbsoluteUrl(this.Url);
}

/// <summary>
Expand All @@ -397,7 +399,7 @@ public override bool HasExternalUrl(HttpContextBase httpContext)
return false;
}
Uri uri = null;
if (Uri.TryCreate(this.url, UriKind.Absolute, out uri))
if (Uri.TryCreate(this.Url, UriKind.Absolute, out uri))
{
return !httpContext.Request.Url.DnsSafeHost.Equals(uri.DnsSafeHost);
}
Expand Down

0 comments on commit 0c8a2f1

Please sign in to comment.