apache/cordova-wp8 — pull request #50 by martincgg (2014-08-19 20:59:25+00:00)
Title: [CB-7338]Remove unwanted slashes in URL, and handle Exceptions when a resource is not found

The URL result of a XHR request, at times contains some unwanted extra slashes, like: 'x-wmapp0: /www or //www'. that URL starting with those slashes, is not well processed by the URI class, so it's required remove them when the 'basePath' is obtained.
Added, regExp to the js script code to remove any ----> ':/, ://, :///' , any slash after 'x-wmapp0:', in that way the URI class it will be successfully resolved and provide the file requested.
Removing unwanted slashes after x-wmapp0 from the basePath, URI cannot process x-wmapp0: /www or //www.

Also added two try-catch statements, over the 'Browser.InvokeScript' statements, if those are not present it throws: 'A first chance exception of type 'System.OutOfMemoryException' occurred in Microsoft.Phone.Interop.ni.dll', stopping the application.
The try-catch statement it would throw this trace when a requested resource is not available, found or not well resolved by the URI class:

ERROR: Exception in HandleCommand: System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
at Microsoft.Phone.Controls.NativeMethods.ValidateHResult(Int32 hr)
at Microsoft.Phone.Controls.WebBrowserInterop.InvokeScript(String scriptName, String[] args)
at Microsoft.Phone.Controls.WebBrowser.InvokeScript(String scriptName, String[] args)
at WPCordovaClassLib.CordovaLib.XHRHelper.HandleCommand(String commandStr)