TinySite.Commands.LoadDocumentsCommand.SanitizeEntryId C# (CSharp) Method

SanitizeEntryId() private static method

private static SanitizeEntryId ( string id ) : string
id string
return string
        private static string SanitizeEntryId(string id)
        {
            if (String.IsNullOrWhiteSpace(id))
            {
                return String.Empty;
            }

            id = Regex.Replace(id, @"[^\w\s_\-\.]+", String.Empty); // first, allow only words, spaces, underscores, dashes and dots.
            id = Regex.Replace(id, @"\.{2,}", String.Empty); // strip out any dots stuck together (no pathing attempts).
            id = Regex.Replace(id, @"\s{2,}", " "); // convert multiple spaces into single space.
            id = id.Trim(' ', '.'); // ensure the string does not start or end with a dot
            return id.Replace(' ', '-').ToLowerInvariant(); // finally, replace all spaces with dashes and lowercase it.
        }