diff --git a/src/Umbraco.Core/StringExtensions.cs b/src/Umbraco.Core/StringExtensions.cs
index b5cb815676..141a8fe28b 100644
--- a/src/Umbraco.Core/StringExtensions.cs
+++ b/src/Umbraco.Core/StringExtensions.cs
@@ -121,8 +121,8 @@ namespace Umbraco.Core
//if the resolution was success, return it, otherwise just return the path, we've detected
// it's a path but maybe it's relative and resolution has failed, etc... in which case we're just
// returning what was given to us.
- return resolvedUrlResult.Success
- ? resolvedUrlResult
+ return resolvedUrlResult.Success
+ ? resolvedUrlResult
: Attempt.Succeed(input);
}
}
@@ -144,7 +144,7 @@ namespace Umbraco.Core
}
internal static readonly Regex Whitespace = new Regex(@"\s+", RegexOptions.Compiled);
- internal static readonly string[] JsonEmpties = new [] { "[]", "{}" };
+ internal static readonly string[] JsonEmpties = new[] { "[]", "{}" };
internal static bool DetectIsEmptyJson(this string input)
{
return JsonEmpties.Contains(Whitespace.Replace(input, string.Empty));
@@ -1436,14 +1436,25 @@ namespace Umbraco.Core
return ReplaceMany(text, regexSpecialCharacters);
}
+ ///
+ /// Checks whether a string "haystack" contains within it any of the strings in the "needles" collection and returns true if it does or false if it doesn't
+ ///
+ /// The string to check
+ /// The collection of strings to check are contained within the first string
+ /// The type of comparision to perform - defaults to
+ /// True if any of the needles are contained with haystack; otherwise returns false
+ /// Added fix to ensure the comparison is used - see http://issues.umbraco.org/issue/U4-11313
public static bool ContainsAny(this string haystack, IEnumerable needles, StringComparison comparison = StringComparison.CurrentCulture)
{
- if (haystack == null) throw new ArgumentNullException("haystack");
- if (string.IsNullOrEmpty(haystack) == false || needles.Any())
+ if (haystack == null)
+ throw new ArgumentNullException("haystack");
+
+ if (string.IsNullOrEmpty(haystack) || needles == null || !needles.Any())
{
- return needles.Any(value => haystack.IndexOf(value) >= 0);
+ return false;
}
- return false;
+
+ return needles.Any(value => haystack.IndexOf(value, comparison) >= 0);
}
public static bool CsvContains(this string csv, string value)