Bloom.Api.EnhancedImageServer.SimulateJavaScriptHandlingOfHtml C# (CSharp) Method

SimulateJavaScriptHandlingOfHtml() public static method

When JavaScript inserts a url into an html document, it replaces the three magic html characters with these substitutes.
Also used by PretendRequestInfo for testing
public static SimulateJavaScriptHandlingOfHtml ( string url ) : string
url string
return string
        public static string SimulateJavaScriptHandlingOfHtml(string url)
        {
            return url.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;");
        }

Usage Example

Example #1
0
        public PretendRequestInfo(string url, HttpMethods httpMethod = HttpMethods.Get, bool forPrinting = false, bool forSrcAttr = false)
        {
            HttpMethod = httpMethod;
            if (forPrinting)
            {
                url = url.Replace("/bloom/", "/bloom/OriginalImages/");
            }

            // In the real request, RawUrl does not include this prefix
            RawUrl = url.Replace(ServerBase.ServerUrl, "");

            // When JavaScript inserts a real path into the html it replaces the three magic html characters with these substitutes.
            // For this PretendRequestInfo we simulate that by doing the replace here in the url.
            if (forSrcAttr)
            {
                url = EnhancedImageServer.SimulateJavaScriptHandlingOfHtml(url);
            }

            // Reducing the /// emulates a behavior of the real HttpListener
            LocalPathWithoutQuery = url.Replace(ServerBase.ServerUrl, "").Replace("/bloom/OriginalImages///", "/bloom/OriginalImages/").Replace("/bloom///", "/bloom/").UnescapeCharsForHttp();
        }