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
23 changes: 19 additions & 4 deletions src/MarkdownSnippets/SnippetExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,23 @@ public static Dictionary<string, IReadOnlyList<Snippet>> ToDictionary(this IEnum
keySelector: _ => _.Key,
elementSelector: _ => _.OrderBy(ScrubPath).ToReadonlyList());

static string? ScrubPath(Snippet snippet) =>
snippet.Path?
.Replace("/", "")
.Replace("\\", "");
static string? ScrubPath(Snippet snippet)
{
var path = snippet.Path;
if (path == null)
{
return null;
}

var builder = StringBuilderCache.Acquire(path.Length);
foreach (var ch in path)
{
if (ch is not ('/' or '\\'))
{
builder.Append(ch);
}
}

return StringBuilderCache.GetStringAndRelease(builder);
}
}