Skip to content

Commit 06f2408

Browse files
authored
Fix for #11977 - Content Name auto-numbering correction (#11996)
1 parent a53d283 commit 06f2408

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/Umbraco.Infrastructure/Persistence/Repositories/Implement/SimilarNodeName.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.Globalization;
33
using System.Linq;
44
using System.Text.RegularExpressions;
@@ -51,7 +51,22 @@ public static string GetUniqueName(IEnumerable<string> names, string name)
5151
}
5252
}
5353

54-
// no suffix - name without suffix does NOT exist, AND name with suffix does NOT exist
54+
// no suffix - name without suffix does NOT exist - we can just use the name without suffix.
55+
if (!model.Suffix.HasValue && !items.SimpleNameExists(model.Text))
56+
{
57+
model.Suffix = StructuredName.NO_SUFFIX;
58+
59+
return model.FullName;
60+
}
61+
62+
// suffix - name with suffix does NOT exist
63+
// We can just return the full name as it is as there's no conflict.
64+
if (model.Suffix.HasValue && !items.SimpleNameExists(model.FullName))
65+
{
66+
return model.FullName;
67+
}
68+
69+
// no suffix - name without suffix does NOT exist, AND name with suffix does NOT exist
5570
if (!model.Suffix.HasValue && !items.SimpleNameExists(model.Text) && !items.SuffixedNameExists())
5671
{
5772
model.Suffix = StructuredName.NO_SUFFIX;
@@ -163,7 +178,7 @@ internal class StructuredName
163178
internal static readonly uint? NO_SUFFIX = default;
164179

165180
internal string Text { get; set; }
166-
internal uint ? Suffix { get; set; }
181+
internal uint? Suffix { get; set; }
167182
public string FullName
168183
{
169184
get

0 commit comments

Comments
 (0)