minibar/support.js: recognize relative URLs as locations on the same server

This means that the relative grammar directory location in the default
configuration will result in AJAX requests rather than the less efficient
JSONP requests.
This commit is contained in:
hallgren
2011-03-01 14:47:20 +00:00
parent a01704fd3e
commit 45b59b0e7e

View File

@@ -90,7 +90,9 @@ function ajax_http_get_json(url,cont) {
}
function sameOrigin(url) {
return hasPrefix(url,location.protocol+"//"+location.host+"/");
var a=empty("a");
a.href=url; // converts to an absolute URL
return hasPrefix(a.href,location.protocol+"//"+location.host+"/");
}
// Use AJAX when possible, fallback to JSONP