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