Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Failed to parse url" error when fetching a relative url #39

Closed
blaise-io opened this issue Feb 5, 2014 · 5 comments
Closed

"Failed to parse url" error when fetching a relative url #39

blaise-io opened this issue Feb 5, 2014 · 5 comments

Comments

@blaise-io
Copy link

When I fetch a relative url, I get these errors on master:
LOG: xdomain (http://blaise.local:8000): failed to parse url: /some/relative/url/

I would expect relative url's (protocol-relative, host-relative) to work. Maybe patch parseUrl to prepend the master's protocol if the protocol is unspecified, and return the master's origin if no hostname is specified?

Environment: Windows 7, IE9, Strict mode.

@jpillora
Copy link
Owner

jpillora commented Feb 5, 2014

Ah, that's just a noisy parse function. Relative URLs are destined for the current origin, so XDomain will not hook them. The log is XDomain failing to find an origin in the URL and therefore ignores it, though normal XHR should still work. This should only appear when debug is enabled. If it's not working, then I'm quite sure it's something else, most likely related to #38. Hard to debug atm since I don't have a Win7 machine active, will need to create a VM i guess...

@blaise-io
Copy link
Author

I can also reproduce it in the latest Firefox, if that helps your testing :)
In my project I'm only using this library for IE9 and below.

I managed to patch it quick-and-dirty using the code below, but I'm sure there's a more elegant way of fixing this.

        if (url) {
            // Patch protocol-relative URL
            if (url.match(/^\/\//)) {
                url = location.protocol + url;
            }
            // Patch domain-relative URL
            else if (url.match(/^\//)) {
                url = location.protocol + '//' + location.host + url;
            }
        }

@jpillora
Copy link
Owner

jpillora commented Feb 5, 2014

Oh damn, just tested, its all browsers - requests to relative URLs fail, investigating now...

@jpillora
Copy link
Owner

jpillora commented Feb 5, 2014

fixed, thanks for the heads up, turns out i was missing 4 characters: if p

@blaise-io
Copy link
Author

Thanks for fixing the relative url issue so quickly!

However, I still have an issue when using protocol-relative url's.
Could you also pick up this specific issue? (reproducable in IE and Firefox)

  • Fetching https://master.example.org/path.html works fine.
  • Fetching //master.example.org/path.html shows an error:
    xdomain (https://slave.example.org): failed to parse url: //master.example.org/path.html

I'm using data-master="*" on my slave.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants