Skip to content
Merged
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
6 changes: 5 additions & 1 deletion src/BootstrapBlazor.Server/Services/CodeSnippetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ namespace BootstrapBlazor.Server.Services;
/// <param name="factory"></param>
/// <param name="cacheManager"></param>
/// <param name="options"></param>
/// <param name="configuration"></param>
/// <param name="localizerOptions"></param>
class CodeSnippetService(
IHttpClientFactory factory,
ICacheManager cacheManager,
IOptions<WebsiteOptions> options,
IConfiguration configuration,
IOptions<JsonLocalizationOptions> localizerOptions)
{
/// <summary>
Expand Down Expand Up @@ -88,7 +90,7 @@ private async Task<string> ReadFileAsync(string fileName)
string? payload;
var file = options.Value.IsDevelopment
? $"{options.Value.ContentRootPath}\\..\\BootstrapBlazor.Server\\Components\\Samples\\{fileName}"
: $"{options.Value.SourceCodePath}BootstrapBlazor.Server\\Components\\Samples\\{fileName}";
: $"{GetSourceCodePath()}BootstrapBlazor.Server\\Components\\Samples\\{fileName}";
if (!OperatingSystem.IsWindows())
{
file = file.Replace('\\', '/');
Expand All @@ -104,6 +106,8 @@ private async Task<string> ReadFileAsync(string fileName)
return payload;
}

private string GetSourceCodePath() => $"{configuration.GetValue<string>("SourceCodePath") ?? options.Value.SourceCodePath}";

private static string ReplaceSymbols(string payload) => payload
.Replace("@@", "@")
.Replace("&lt;", "<")
Expand Down