Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clicking link in comment opens in new tab #8060

Merged
merged 3 commits into from
Apr 10, 2024
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