Why does Javascript treat relative URLs differently than standard HTML? Think of the following URL (or just browse to it): http://en.wikipedia.org/wiki/Rome. Open a Firebug console (or another Javascript console) and enter the following:
var x = new XMLHttpRequest();
x.open("GET", "foo", true);
x.send("bar");
Under my system the request is sent to "http://en.wikipedia.org/wiki/foo". The "Rome" in the URL is simply ignored. The same request with a trailing slash in the URL ("http://en.wikipedia.org/wiki/Rome/") appends the "foo" to the full URL.
This seems to make it pretty hard to encode the correct URLs in Javascript. Are there any Javascript libraries that help to overcome this problem?
(I asked a similiar question before, but more jQuery specific, where this also happens. I hope I get a better answer with this somewhat more library independent question.)