Match neutral cultures as Examine culture fields (#9305)
This commit is contained in:
@@ -27,7 +27,7 @@ namespace Umbraco.Examine
|
||||
/// <remarks>
|
||||
/// myFieldName_en-us will match the "en-us"
|
||||
/// </remarks>
|
||||
internal static readonly Regex CultureIsoCodeFieldNameMatchExpression = new Regex("^([_\\w]+)_([a-z]{2}-[a-z0-9]{2,4})$", RegexOptions.Compiled);
|
||||
internal static readonly Regex CultureIsoCodeFieldNameMatchExpression = new Regex("^(?<FieldName>[_\\w]+)_(?<CultureName>[a-z]{2,3}(-[a-z0-9]{2,4})?)$", RegexOptions.Compiled | RegexOptions.ExplicitCapture);
|
||||
|
||||
private static bool _isConfigured = false;
|
||||
private static object _configuredInit = null;
|
||||
@@ -67,7 +67,7 @@ namespace Umbraco.Examine
|
||||
foreach (var field in allFields)
|
||||
{
|
||||
var match = CultureIsoCodeFieldNameMatchExpression.Match(field);
|
||||
if (match.Success && match.Groups.Count == 3 && culture.InvariantEquals(match.Groups[2].Value))
|
||||
if (match.Success && culture.InvariantEquals(match.Groups["CultureName"].Value))
|
||||
yield return field;
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ namespace Umbraco.Examine
|
||||
foreach (var field in allFields)
|
||||
{
|
||||
var match = CultureIsoCodeFieldNameMatchExpression.Match(field);
|
||||
if (match.Success && match.Groups.Count == 3 && culture.InvariantEquals(match.Groups[2].Value))
|
||||
if (match.Success && culture.InvariantEquals(match.Groups["CultureName"].Value))
|
||||
{
|
||||
yield return field; //matches this culture field
|
||||
}
|
||||
|
||||
@@ -73,13 +73,13 @@ namespace Umbraco.Examine
|
||||
return true;
|
||||
|
||||
//before we use regex to match do some faster simple matching since this is going to execute quite a lot
|
||||
if (!fieldName.Contains("_") || !fieldName.Contains("-"))
|
||||
if (!fieldName.Contains("_"))
|
||||
return false;
|
||||
|
||||
var match = ExamineExtensions.CultureIsoCodeFieldNameMatchExpression.Match(fieldName);
|
||||
if (match.Success && match.Groups.Count == 3)
|
||||
if (match.Success)
|
||||
{
|
||||
var nonCultureFieldName = match.Groups[1].Value;
|
||||
var nonCultureFieldName = match.Groups["FieldName"].Value;
|
||||
//check if there's a definition for this and if so return the field definition for the culture field based on the non-culture field
|
||||
if (base.TryGetValue(nonCultureFieldName, out var existingFieldDefinition))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user