Shashank Banerjea created CB-4421:
-------------------------------------

             Summary: WP8 Project - XHRHelper.HandleCommand failing with 
'System.InvalidOperationException: This operation is not supported for a 
relative URI" error
                 Key: CB-4421
                 URL: https://issues.apache.org/jira/browse/CB-4421
             Project: Apache Cordova
          Issue Type: Bug
          Components: WP8
    Affects Versions: 3.0.0
         Environment: Development Environment: Visual Studio 2012 (with Update 
3), Windows 8 x64, 
Target Environment: Windows Phone 8.0
Other libraries - jquery, requirejs
            Reporter: Shashank Banerjea
            Assignee: Jesse MacFadyen


In the WP8 application we are developing, when the following code is being 
executed -

{panel}
$.get("/www/folder/to/devConfig.txt").done( function(content) {
  settings = JSON.parse(content)
} );
{panel}


I get the following exception:

{System.InvalidOperationException: This operation is not supported for a 
relative URI.
   at System.Uri.get_AbsolutePath()
   at WPCordovaClassLib.CordovaLib.XHRHelper.HandleCommand(String commandStr)
   at WPCordovaClassLib.CordovaView.CordovaBrowser_Sc...


I tried various combination such as:
 - "file:///www/folder/to/devConfig.txt" and 
"file://localhost/folder/to/devConfig.txt", which translated to 
"/www/folder/to/devConfig.txt", in the relative path.

In these cases I received a 404 error.

Reading through the documentation, it seems that the first "/" needs to be 
removed for the relative path to work, instead of 
"/www/folder/to/devConfig.txt" should be "www/folder/to/devconfig.txt".

Sending "www/folder/to/devconfig.txt", causes the first exception.

As a fix, I have modified the XHRHelper code to check for isAbsoluteUri 
condition and remove the first "/" if it is a relative path. That seems to 
work. But it is not a future proof solution.

Please advise.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to