Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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, "<a(?!.*?target=)(.*?)>", "<a$1 target=\"_blank\" rel=\"noopener noreferrer\">");
}
}
}
4 changes: 2 additions & 2 deletions src/dotnet/APIView/APIViewWeb/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>("APPCONFIG");
// Load configuration from Azure App Configuration
Expand All @@ -28,6 +27,7 @@ public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
kv.SetCredential(new DefaultAzureCredential());
});
});
config.AddUserSecrets(typeof(Program).Assembly);
})
.UseStartup<Startup>();
}
Expand Down