From 3b5c8404bd338d8982a9d62366c2346be0a1d5d8 Mon Sep 17 00:00:00 2001 From: Whitney Shake <106706358+WhitShake@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:10:16 -0400 Subject: [PATCH] Clicking link in comment opens in new tab (#8060) * Added comments open in new tab functionality, testing needed * Open comment link in new tab complete * Corrected program.cs --- .../APIView/APIViewWeb/CommentMarkdownExtensions.cs | 9 ++++++++- src/dotnet/APIView/APIViewWeb/Program.cs | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/dotnet/APIView/APIViewWeb/CommentMarkdownExtensions.cs b/src/dotnet/APIView/APIViewWeb/CommentMarkdownExtensions.cs index 004c98b3251..9784b3257b6 100644 --- a/src/dotnet/APIView/APIViewWeb/CommentMarkdownExtensions.cs +++ b/src/dotnet/APIView/APIViewWeb/CommentMarkdownExtensions.cs @@ -18,7 +18,9 @@ public static IHtmlContent FormatAsMarkdown(this IHtmlHelper helper, string text { try { - return new HtmlString(MarkdownAsHtml(text)); + string htmlContent = MarkdownAsHtml(text); + htmlContent = AddTargetBlankToLinks(htmlContent); + return new HtmlString(htmlContent); } catch { @@ -31,5 +33,10 @@ public static string MarkdownAsHtml(string text) => public static string MarkdownAsPlainText(string text) => Markdown.ToPlainText(text ?? "", MarkdownPipeline); + + private static string AddTargetBlankToLinks(string htmlContent) + { + return System.Text.RegularExpressions.Regex.Replace(htmlContent, "", ""); + } } } diff --git a/src/dotnet/APIView/APIViewWeb/Program.cs b/src/dotnet/APIView/APIViewWeb/Program.cs index 1e1ea36dac0..fa97ce46bbb 100644 --- a/src/dotnet/APIView/APIViewWeb/Program.cs +++ b/src/dotnet/APIView/APIViewWeb/Program.cs @@ -16,8 +16,7 @@ public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .ConfigureAppConfiguration((hostingContext, config) => { - config.AddEnvironmentVariables(prefix: "APIVIEW_"); - config.AddUserSecrets(typeof(Program).Assembly); + config.AddEnvironmentVariables(prefix: "APIVIEW_"); IConfiguration settings = config.Build(); string connectionString = settings.GetValue("APPCONFIG"); // Load configuration from Azure App Configuration @@ -28,6 +27,7 @@ public static IWebHostBuilder CreateWebHostBuilder(string[] args) => kv.SetCredential(new DefaultAzureCredential()); }); }); + config.AddUserSecrets(typeof(Program).Assembly); }) .UseStartup(); }