WikiFunctions.Summary.Trim C# (CSharp) Method

Trim() public static method

Truncates an edit summary that's over the maximum supported length
public static Trim ( string summary ) : string
summary string input long edit summary
return string
        public static string Trim(string summary)
        {
            int maxAvailableSummaryLength = ((MaxLength - 5) - (Variables.SummaryTag.Length + 1));
            // https://en.wikipedia.org/wiki/Wikipedia_talk:AutoWikiBrowser/Bugs/Archive_10#Edit_summary_issue
            // replace last wikilink with dots as an attempt to prevent broken wikilinks in edit summary
            if (Encoding.UTF8.GetByteCount(summary) >= maxAvailableSummaryLength && summary.EndsWith(@"]]"))
                summary = SummaryTrim.Replace(summary, "...");

            return (Encoding.UTF8.GetByteCount(summary) > maxAvailableSummaryLength)
                       ? LimitByteLength(summary, maxAvailableSummaryLength)
                : summary;
        }