CreateFromUnencodedString() public static method

public static CreateFromUnencodedString ( string unencoded, bool strictlyTreatAsEncoded = false ) : UrlPathString
unencoded string
strictlyTreatAsEncoded bool
return UrlPathString
Example #1
0
        public static string GetPleaseClickHereForHelpMessage(string pathToProblemFile)
        {
            var template2 = LocalizationManager.GetString("Common.ClickHereForHelp",
                                                          "Please click [here] to get help from the Bloom support team.",
                                                          "[here] will become a link. Keep the brackets to mark the translated text that should form the link.");

            var pattern = new Regex(@"\[(.*)\]");

            if (!pattern.IsMatch(template2))
            {
                // If the translator messed up and didn't mark the bit that should be the hot link, we'll make the whole sentence hot.
                // So it will be something like "Please click here to get help from the Bloom support team", and you can click anywhere
                // on the sentence.
                template2 = "[" + template2 + "]";
            }

            // If we leave backslashes in here, json will fail to parse it later. It works fine with forward slashes, even on Windows.
            pathToProblemFile = pathToProblemFile.Replace("\\", "/");
            var part2 = pattern.Replace(template2,
                                        $"<a href='/bloom/api/teamCollection/reportBadZip?file={UrlPathString.CreateFromUnencodedString(pathToProblemFile).UrlEncoded}'>$1</a>");

            return(part2);
        }