mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
Bug fix
--HG-- branch : dev
This commit is contained in:
@@ -5,9 +5,16 @@ namespace Orchard.ContentTypes.Extensions {
|
||||
public static class StrinExtensions {
|
||||
private static readonly Regex humps = new Regex("[A-Z][^A-Z]*");
|
||||
public static string CamelFriendly(this string camel) {
|
||||
return camel != null
|
||||
? humps.Matches(camel).OfType<Match>().Select(m => m.Value).Aggregate((a, b) => a + " " + b).TrimStart(' ')
|
||||
: null;
|
||||
if (camel == null)
|
||||
return null;
|
||||
|
||||
var matches = humps.Matches(camel).OfType<Match>().Select(m => m.Value);
|
||||
if (matches.Any()) {
|
||||
return matches.Aggregate((a, b) => a + " " + b).TrimStart(' ');
|
||||
}
|
||||
else {
|
||||
return camel;
|
||||
}
|
||||
}
|
||||
|
||||
public static string TrimEnd(this string rough, string trim = "") {
|
||||
@@ -15,7 +22,7 @@ namespace Orchard.ContentTypes.Extensions {
|
||||
return null;
|
||||
|
||||
return rough.EndsWith(trim)
|
||||
? rough.Substring(0, rough.Length - 4)
|
||||
? rough.Substring(0, rough.Length - trim.Length)
|
||||
: rough;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user