Skip to content

Commit

Permalink
Fix functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros committed Nov 9, 2024
1 parent 8776fff commit 621e07c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed class DashboardPartContentTypeDefinitionHandler : IContentDefiniti
/// </summary>
public void ContentTypeBuilding(ContentTypeBuildingContext context)
{
if (!context.Record.Settings.TryGetPropertyValue(nameof(ContentTypeSettings), out var node))
if (context?.Record?.Settings is null || !context.Record.Settings.TryGetPropertyValue(nameof(ContentTypeSettings), out var node))
{
return;
}
Expand Down Expand Up @@ -52,7 +52,7 @@ public void ContentTypeBuilding(ContentTypeBuildingContext context)
/// </summary>
public void ContentTypePartBuilding(ContentTypePartBuildingContext context)
{
if (!context.Record.PartName.EqualsOrdinalIgnoreCase(nameof(DashboardPart)))
if (context?.Record?.Settings is null || !context.Record.PartName.EqualsOrdinalIgnoreCase(nameof(DashboardPart)))
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
using System.Buffers;

namespace OrchardCore.DisplayManagement.Utilities;

public static class StringExtensions
{
private static readonly SearchValues<char> AlternateChars = SearchValues.Create("-.");

/// <summary>
/// Encodes dashed and dots so that they don't conflict in filenames.
/// </summary>
/// <param name="alternateElement"></param>
/// <returns></returns>
public static string EncodeAlternateElement(this string alternateElement)
{
if (string.IsNullOrEmpty(alternateElement))
{
return "";
}

if (!alternateElement.AsSpan().ContainsAny(AlternateChars))
{
return alternateElement;
}

return alternateElement.Replace("-", "__").Replace('.', '_');
}
}

0 comments on commit 621e07c

Please sign in to comment.