diff --git a/src/DocNet/Docnet.csproj b/src/DocNet/Docnet.csproj
index 2340235..99b3653 100644
--- a/src/DocNet/Docnet.csproj
+++ b/src/DocNet/Docnet.csproj
@@ -65,6 +65,7 @@
+
diff --git a/src/DocNet/INavigationElementExtensions.cs b/src/DocNet/INavigationElementExtensions.cs
new file mode 100644
index 0000000..ce7138d
--- /dev/null
+++ b/src/DocNet/INavigationElementExtensions.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Web;
+
+namespace Docnet
+{
+ public static class INavigationElementExtensions
+ {
+ ///
+ /// Gets the final URL by encoding the path and by removing the filename if it equals index.htm.
+ ///
+ /// The navigation element.
+ /// The path specification.
+ ///
+ public static string GetFinalTargetUrl(this INavigationElement navigationElement, PathSpecification pathSpecification)
+ {
+ var targetUrl = navigationElement.GetTargetURL(pathSpecification);
+ var link = HttpUtility.UrlPathEncode(targetUrl);
+
+ if (link.EndsWith("index.htm", StringComparison.InvariantCultureIgnoreCase))
+ {
+ link = link.Substring(0, link.Length - "index.htm".Length);
+ }
+
+ return link;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/DocNet/NavigationLevel.cs b/src/DocNet/NavigationLevel.cs
index ab0a633..ba1d781 100644
--- a/src/DocNet/NavigationLevel.cs
+++ b/src/DocNet/NavigationLevel.cs
@@ -180,14 +180,8 @@ namespace Docnet
}
else
{
- var link = HttpUtility.UrlPathEncode(indexElement.GetTargetURL(pathSpecification));
- if (link.EndsWith("index.htm",StringComparison.InvariantCultureIgnoreCase))
- {
- link = link.Substring(0, link.Length - "index.htm".Length);
- }
-
fragments.Add(string.Format("{0}{3}",
- elementStartTag, relativePathToRoot, link, this.Name));
+ elementStartTag, relativePathToRoot, indexElement.GetFinalTargetUrl(pathSpecification), this.Name));
}
}
// then the elements in the container. Index elements are skipped here.
@@ -199,15 +193,9 @@ namespace Docnet
}
else
{
- var link = HttpUtility.UrlPathEncode(this.GetTargetURL(pathSpecification));
- if (link.EndsWith("index.htm", StringComparison.InvariantCultureIgnoreCase))
- {
- link = link.Substring(0, link.Length - "index.htm".Length);
- }
-
// just a link
fragments.Add(string.Format(" {2}",
- relativePathToRoot, link, this.Name));
+ relativePathToRoot, this.GetFinalTargetUrl(pathSpecification), this.Name));
}
if (!this.IsRoot)
{
diff --git a/src/DocNet/SimpleNavigationElement.cs b/src/DocNet/SimpleNavigationElement.cs
index 052bf5f..db9df9b 100644
--- a/src/DocNet/SimpleNavigationElement.cs
+++ b/src/DocNet/SimpleNavigationElement.cs
@@ -89,7 +89,8 @@ namespace Docnet
{
continue;
}
- defaultMarkdown.AppendFormat("* [{0}]({1}{2}){3}", sibling.Name, relativePathToRoot, HttpUtility.UrlPathEncode(sibling.GetTargetURL(pathSpecification)), Environment.NewLine);
+ defaultMarkdown.AppendFormat("* [{0}]({1}{2}){3}", sibling.Name, relativePathToRoot,
+ sibling.GetFinalTargetUrl(pathSpecification), Environment.NewLine);
}
defaultMarkdown.Append(Environment.NewLine);
content = Utils.ConvertMarkdownToHtml(defaultMarkdown.ToString(), Path.GetDirectoryName(destinationFile), activeConfig.Destination, string.Empty, _relativeH2LinksOnPage, activeConfig.ConvertLocalLinks);
@@ -189,7 +190,7 @@ namespace Docnet
string.IsNullOrWhiteSpace(liClass) ? string.Empty : string.Format(" class=\"{0}\"", liClass),
string.IsNullOrWhiteSpace(aClass) ? string.Empty : string.Format(" class=\"{0}\"", aClass),
relativePathToRoot,
- HttpUtility.UrlPathEncode(this.GetTargetURL(pathSpecification)),
+ this.GetFinalTargetUrl(pathSpecification),
this.Name));
if(isCurrent && _relativeH2LinksOnPage.Any())
{