From 409e4de67968661b1bd9891121cfc225ec2b3456 Mon Sep 17 00:00:00 2001 From: Geert van Horrik Date: Tue, 27 Jun 2017 18:05:23 +0200 Subject: [PATCH] Don't remove index.htm when it's the only content of a link --- src/DocNet/INavigationElementExtensions.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/DocNet/INavigationElementExtensions.cs b/src/DocNet/INavigationElementExtensions.cs index ce7138d..0b60fb3 100644 --- a/src/DocNet/INavigationElementExtensions.cs +++ b/src/DocNet/INavigationElementExtensions.cs @@ -5,6 +5,8 @@ namespace Docnet { public static class INavigationElementExtensions { + private const string IndexHtmFileName = "index.htm"; + /// /// Gets the final URL by encoding the path and by removing the filename if it equals index.htm. /// @@ -16,9 +18,9 @@ namespace Docnet var targetUrl = navigationElement.GetTargetURL(pathSpecification); var link = HttpUtility.UrlPathEncode(targetUrl); - if (link.EndsWith("index.htm", StringComparison.InvariantCultureIgnoreCase)) + if (link.Length > IndexHtmFileName.Length && link.EndsWith(IndexHtmFileName, StringComparison.InvariantCultureIgnoreCase)) { - link = link.Substring(0, link.Length - "index.htm".Length); + link = link.Substring(0, link.Length - IndexHtmFileName.Length); } return link;