From 464713c35dfb66a452c8176f8004985394b5af29 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 26 Oct 2018 10:22:24 +0300 Subject: [PATCH] Allow external link on the navigation area. --- .../Helpers/TagHelpers/TreeTagHelper.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/docs/src/Volo.Docs.Web/Areas/Documents/Helpers/TagHelpers/TreeTagHelper.cs b/modules/docs/src/Volo.Docs.Web/Areas/Documents/Helpers/TagHelpers/TreeTagHelper.cs index 07be0cf97d..3657896c67 100644 --- a/modules/docs/src/Volo.Docs.Web/Areas/Documents/Helpers/TagHelpers/TreeTagHelper.cs +++ b/modules/docs/src/Volo.Docs.Web/Areas/Documents/Helpers/TagHelpers/TreeTagHelper.cs @@ -116,6 +116,11 @@ namespace Volo.Docs.Areas.Documents.Helpers.TagHelpers private string NormalizePath(string path, bool hasChildItems) { + if (IsExternalLink(path)) + { + return path; + } + var pathWithoutFileExtension = RemoveFileExtensionFromPath(path); if (string.IsNullOrWhiteSpace(path)) @@ -126,6 +131,16 @@ namespace Volo.Docs.Areas.Documents.Helpers.TagHelpers return "/documents/" + ProjectName + "/" + Version + "/" + pathWithoutFileExtension; } + protected virtual bool IsExternalLink(string path) + { + if (path.IsNullOrEmpty()) + { + return false; + } + + return path.StartsWith("http") || path.StartsWith("https"); + } + private string RemoveFileExtensionFromPath(string path) { if (path == null) @@ -137,6 +152,5 @@ namespace Volo.Docs.Areas.Documents.Helpers.TagHelpers ? path.Left(path.Length - ProjectFormat.Length - 1) : path; } - } }