Making it so createUrlObject casts all urls to absolute ones first. r=crschmidt (pullup #2060)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9404 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1346,7 +1346,21 @@ OpenLayers.Util.isEquivalentUrl = function(url1, url2, options) {
|
||||
OpenLayers.Util.createUrlObject = function(url, options) {
|
||||
options = options || {};
|
||||
|
||||
var urlObject = {};
|
||||
// deal with relative urls first
|
||||
if(!(/^\w+:\/\//).test(url)) {
|
||||
var loc = window.location;
|
||||
var port = loc.port ? ":" + loc.port : "";
|
||||
var fullUrl = loc.protocol + "//" + loc.host + port;
|
||||
if(url.indexOf("/") === 0) {
|
||||
// full pathname
|
||||
url = fullUrl + url;
|
||||
} else {
|
||||
// relative to current path
|
||||
var parts = loc.pathname.split("/");
|
||||
parts.pop();
|
||||
url = fullUrl + parts.join("/") + "/" + url;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.ignoreCase) {
|
||||
url = url.toLowerCase();
|
||||
@@ -1355,13 +1369,15 @@ OpenLayers.Util.createUrlObject = function(url, options) {
|
||||
var a = document.createElement('a');
|
||||
a.href = url;
|
||||
|
||||
var urlObject = {};
|
||||
|
||||
//host (without port)
|
||||
// if we don't have a host (which is the case with URLs starting with "/"
|
||||
// in IE), take the window location's host to match other browsers that
|
||||
// fill in the window's location host automatically
|
||||
urlObject.host = a.host || window.location.host;
|
||||
var port = a.port;
|
||||
if (port.length <= 0) {
|
||||
if (port.length > 0) {
|
||||
var newHostLength = urlObject.host.length - (port.length);
|
||||
urlObject.host = urlObject.host.substring(0, newHostLength);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user