jpillora / xdomain

A pure JavaScript CORS alternative
https://jpillora.com/xdomain/
3.12k stars 269 forks source link

Failed to parse absolute url error #173

Closed henryruhs closed 5 years ago

henryruhs commented 8 years ago

Failed to parse relative url to files data/test.json with version 0.7.3.

Here comes some debug code from the IE9 console:

>>> location.protocol
"https:"

>>> xdomain.parseUrl('data/test.json');
LOG: xdomain (https://this-is-my-slave-url): failed to parse absolute url: data/test.json

>>> xdomain.parseUrl('/data/test.json');
LOG: xdomain (https://this-is-my-slave-url): failed to parse absolute url: /data/test.json

>>> xdomain.parseUrl('//data/test.json');
{
   origin : "https://data",
   path : "test.json"
}
henryruhs commented 8 years ago

I fixed a couple of certificate errors. This magically fixed my xdomain integration.

Maby parseUrl() fails on invalid certificates? Can you confirm that?

jpillora commented 8 years ago

Interesting bug, maybe it failed to convert a protocoless scheme to httpa and so it just left it as //

Good ol IE :) On Tue, 20 Oct 2015 at 10:38 PM Henry Ruhs notifications@github.com wrote:

I fixed a couple of certificate errors. This fixed it, is that possible?

— Reply to this email directly or view it on GitHub https://github.com/jpillora/xdomain/issues/173#issuecomment-149534648.

henryruhs commented 8 years ago

My team needs a fix for that, can we give you a helpful hand? Please suggest where to start?

jpillora commented 8 years ago

Still occurring after you've fixed your certificates? On Sat, 24 Oct 2015 at 2:42 AM Henry Ruhs notifications@github.com wrote:

My team needs a fix for that, can we give you a helpful hand? Please suggest where to start?

— Reply to this email directly or view it on GitHub https://github.com/jpillora/xdomain/issues/173#issuecomment-150612001.

henryruhs commented 8 years ago

I fixed the certificates but some AJAX requests to local based services / relative urls cause a crash of the Javascript by xdomain because of the parse error.

jpillora commented 8 years ago

it shouldn't be crashing, it should just log a message

https://github.com/jpillora/xdomain/blob/gh-pages/dist/xdomain.js#L1044-L1054

and it shouldn't even appear unless you have debug mode on

https://github.com/jpillora/xdomain/blob/gh-pages/dist/xdomain.js#L1009

parseUrl should fail on relative URLs as relative URLs are same domain and XDomain can ignore them. aside from the failed to parse error, what's actually going wrong?

On Sat, Oct 24, 2015 at 10:44 PM Henry Ruhs notifications@github.com wrote:

I fixed the certificates but some AJAX requests to local based services / relative urls cause a crash of the Javascript by xdomain because of the parse error.

— Reply to this email directly or view it on GitHub https://github.com/jpillora/xdomain/issues/173#issuecomment-150797509.