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(); }