Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e15c50cd8f | |||
| 0b0d04b637 |
@@ -412,7 +412,7 @@ OpenLayers.Layer.ArcIMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
|||||||
|
|
||||||
if (!arcxml.iserror()) {
|
if (!arcxml.iserror()) {
|
||||||
// if the arcxml is not an error, call the callback with the features parsed
|
// if the arcxml is not an error, call the callback with the features parsed
|
||||||
callback.call(scope, arcxml.features);
|
callback.call(scope, response.features);
|
||||||
} else {
|
} else {
|
||||||
// if the arcxml is an error, return null features selected
|
// if the arcxml is an error, return null features selected
|
||||||
callback.call(scope, null);
|
callback.call(scope, null);
|
||||||
|
|||||||
+21
-104
@@ -1282,36 +1282,13 @@ OpenLayers.Util.isEquivalentUrl = function(url1, url2, options) {
|
|||||||
var urlObj1 = OpenLayers.Util.createUrlObject(url1, options);
|
var urlObj1 = OpenLayers.Util.createUrlObject(url1, options);
|
||||||
var urlObj2 = OpenLayers.Util.createUrlObject(url2, options);
|
var urlObj2 = OpenLayers.Util.createUrlObject(url2, options);
|
||||||
|
|
||||||
//compare all keys (host, port, etc)
|
//compare all keys except for "args" (treated below)
|
||||||
for(var key in urlObj1) {
|
for(var key in urlObj1) {
|
||||||
if (options.test) {
|
if(key !== "args") {
|
||||||
OpenLayers.Console.userError(key + "\n1:" + urlObj1[key] + "\n2:" + urlObj2[key]);
|
if(urlObj1[key] != urlObj2[key]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var val1 = urlObj1[key];
|
|
||||||
var val2 = urlObj2[key];
|
|
||||||
|
|
||||||
switch(key) {
|
|
||||||
case "args":
|
|
||||||
//do nothing, they'll be treated below
|
|
||||||
break;
|
|
||||||
case "host":
|
|
||||||
case "port":
|
|
||||||
case "protocol":
|
|
||||||
if ((val1 == "") || (val2 == "")) {
|
|
||||||
//these will be blank for relative urls, so no need to
|
|
||||||
// compare them here -- call break.
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// otherwise continue with default compare
|
|
||||||
//
|
|
||||||
default:
|
|
||||||
if ( (key != "args") && (urlObj1[key] != urlObj2[key]) ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// compare search args - irrespective of order
|
// compare search args - irrespective of order
|
||||||
@@ -1350,7 +1327,7 @@ OpenLayers.Util.createUrlObject = function(url, options) {
|
|||||||
if(!(/^\w+:\/\//).test(url)) {
|
if(!(/^\w+:\/\//).test(url)) {
|
||||||
var loc = window.location;
|
var loc = window.location;
|
||||||
var port = loc.port ? ":" + loc.port : "";
|
var port = loc.port ? ":" + loc.port : "";
|
||||||
var fullUrl = loc.protocol + "//" + loc.host + port;
|
var fullUrl = loc.protocol + "//" + loc.host.split(":").shift() + port;
|
||||||
if(url.indexOf("/") === 0) {
|
if(url.indexOf("/") === 0) {
|
||||||
// full pathname
|
// full pathname
|
||||||
url = fullUrl + url;
|
url = fullUrl + url;
|
||||||
@@ -1371,27 +1348,23 @@ OpenLayers.Util.createUrlObject = function(url, options) {
|
|||||||
|
|
||||||
var urlObject = {};
|
var urlObject = {};
|
||||||
|
|
||||||
//host (without port)
|
//host (without port)
|
||||||
// if we don't have a host (which is the case with URLs starting with "/"
|
urlObject.host = a.host.split(":").shift();
|
||||||
// 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) {
|
|
||||||
var newHostLength = urlObject.host.length - (port.length);
|
|
||||||
urlObject.host = urlObject.host.substring(0, newHostLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
//protocol
|
//protocol
|
||||||
urlObject.protocol = a.protocol;
|
urlObject.protocol = a.protocol;
|
||||||
|
|
||||||
//port
|
//port (get uniform browser behavior with port 80 here)
|
||||||
urlObject.port = ((port == "80") && (options.ignorePort80)) ? "" : port;
|
if(options.ignorePort80) {
|
||||||
|
urlObject.port = (a.port == "80" || a.port == "0") ? "" : a.port;
|
||||||
//hash
|
} else {
|
||||||
urlObject.hash = (options.ignoreHash) ? "" : a.hash;
|
urlObject.port = (a.port == "" || a.port == "0") ? "80" : a.port;
|
||||||
|
}
|
||||||
|
|
||||||
|
//hash
|
||||||
|
urlObject.hash = (options.ignoreHash || a.hash === "#") ? "" : a.hash;
|
||||||
|
|
||||||
//args
|
//args
|
||||||
var queryString = a.search;
|
var queryString = a.search;
|
||||||
if (!queryString) {
|
if (!queryString) {
|
||||||
var qMark = url.indexOf("?");
|
var qMark = url.indexOf("?");
|
||||||
@@ -1399,65 +1372,9 @@ OpenLayers.Util.createUrlObject = function(url, options) {
|
|||||||
}
|
}
|
||||||
urlObject.args = OpenLayers.Util.getParameters(queryString);
|
urlObject.args = OpenLayers.Util.getParameters(queryString);
|
||||||
|
|
||||||
//pathname (this part allows for relative <-> absolute comparison)
|
//pathname (uniform browser behavior with leading "/")
|
||||||
if ( ((urlObject.protocol == "file:") && (url.indexOf("file:") != -1)) ||
|
urlObject.pathname = (a.pathname.charAt(0) == "/") ? a.pathname : "/" + a.pathname;
|
||||||
((urlObject.protocol != "file:") && (urlObject.host != "")) ) {
|
|
||||||
|
|
||||||
urlObject.pathname = a.pathname;
|
|
||||||
|
|
||||||
//Test to see if the pathname includes the arguments (Opera)
|
|
||||||
var qIndex = urlObject.pathname.indexOf("?");
|
|
||||||
if (qIndex != -1) {
|
|
||||||
urlObject.pathname = urlObject.pathname.substring(0, qIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
var relStr = OpenLayers.Util.removeTail(url);
|
|
||||||
|
|
||||||
var backs = 0;
|
|
||||||
do {
|
|
||||||
var index = relStr.indexOf("../");
|
|
||||||
|
|
||||||
if (index == 0) {
|
|
||||||
backs++;
|
|
||||||
relStr = relStr.substr(3);
|
|
||||||
} else if (index >= 0) {
|
|
||||||
var prevChunk = relStr.substr(0,index - 1);
|
|
||||||
|
|
||||||
var slash = prevChunk.indexOf("/");
|
|
||||||
prevChunk = (slash != -1) ? prevChunk.substr(0, slash +1)
|
|
||||||
: "";
|
|
||||||
|
|
||||||
var postChunk = relStr.substr(index + 3);
|
|
||||||
relStr = prevChunk + postChunk;
|
|
||||||
}
|
|
||||||
} while(index != -1);
|
|
||||||
|
|
||||||
var windowAnchor = document.createElement("a");
|
|
||||||
var windowUrl = window.location.href;
|
|
||||||
if (options.ignoreCase) {
|
|
||||||
windowUrl = windowUrl.toLowerCase();
|
|
||||||
}
|
|
||||||
windowAnchor.href = windowUrl;
|
|
||||||
|
|
||||||
//set protocol of window
|
|
||||||
urlObject.protocol = windowAnchor.protocol;
|
|
||||||
|
|
||||||
var splitter = (windowAnchor.pathname.indexOf("/") != -1) ? "/" : "\\";
|
|
||||||
var dirs = windowAnchor.pathname.split(splitter);
|
|
||||||
dirs.pop(); //remove filename
|
|
||||||
while ((backs > 0) && (dirs.length > 0)) {
|
|
||||||
dirs.pop();
|
|
||||||
backs--;
|
|
||||||
}
|
|
||||||
relStr = dirs.join("/") + "/"+ relStr;
|
|
||||||
urlObject.pathname = relStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((urlObject.protocol == "file:") || (urlObject.protocol == "")) {
|
|
||||||
urlObject.host = "localhost";
|
|
||||||
}
|
|
||||||
|
|
||||||
return urlObject;
|
return urlObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+110
@@ -680,6 +680,116 @@
|
|||||||
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "absolute and relative path without host works for "+url2)
|
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "absolute and relative path without host works for "+url2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_createUrlObject(t) {
|
||||||
|
|
||||||
|
var cases = [{
|
||||||
|
url: "http://example.com/",
|
||||||
|
exp: {
|
||||||
|
protocol: "http:",
|
||||||
|
host: "example.com",
|
||||||
|
port: "80",
|
||||||
|
pathname: "/",
|
||||||
|
args: {},
|
||||||
|
hash: ""
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
url: "http://example.com:80/",
|
||||||
|
opt: {ignorePort80: true},
|
||||||
|
exp: {
|
||||||
|
protocol: "http:",
|
||||||
|
host: "example.com",
|
||||||
|
port: "",
|
||||||
|
pathname: "/",
|
||||||
|
args: {},
|
||||||
|
hash: ""
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
url: "http://example.com/",
|
||||||
|
opt: {ignorePort80: true},
|
||||||
|
exp: {
|
||||||
|
protocol: "http:",
|
||||||
|
host: "example.com",
|
||||||
|
port: "",
|
||||||
|
pathname: "/",
|
||||||
|
args: {},
|
||||||
|
hash: ""
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
url: "http://example.com:88/",
|
||||||
|
exp: {
|
||||||
|
protocol: "http:",
|
||||||
|
host: "example.com",
|
||||||
|
port: "88",
|
||||||
|
pathname: "/",
|
||||||
|
args: {},
|
||||||
|
hash: ""
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
url: "http://example.com:88/foo#bar",
|
||||||
|
exp: {
|
||||||
|
protocol: "http:",
|
||||||
|
host: "example.com",
|
||||||
|
port: "88",
|
||||||
|
pathname: "/foo",
|
||||||
|
args: {},
|
||||||
|
hash: "#bar"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
url: "http://example.com:88/?foo=bar",
|
||||||
|
exp: {
|
||||||
|
protocol: "http:",
|
||||||
|
host: "example.com",
|
||||||
|
port: "88",
|
||||||
|
pathname: "/",
|
||||||
|
args: {foo: "bar"},
|
||||||
|
hash: ""
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
url: "http://example.com/bogus/../bogus/../path",
|
||||||
|
exp: {
|
||||||
|
protocol: "http:",
|
||||||
|
host: "example.com",
|
||||||
|
port: "80",
|
||||||
|
pathname: "/path",
|
||||||
|
args: {},
|
||||||
|
hash: ""
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
url: "/relative#foo",
|
||||||
|
exp: {
|
||||||
|
protocol: window.location.protocol,
|
||||||
|
host: window.location.hostname,
|
||||||
|
port: window.location.port || "80",
|
||||||
|
pathname: "/relative",
|
||||||
|
args: {},
|
||||||
|
hash: "#foo"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
url: "../foo",
|
||||||
|
exp: {
|
||||||
|
protocol: window.location.protocol,
|
||||||
|
host: window.location.hostname,
|
||||||
|
port: window.location.port || "80",
|
||||||
|
pathname: (function() {
|
||||||
|
var parts = window.location.pathname.split("/");
|
||||||
|
return parts.slice(0, parts.length -2).join("/") + "/foo";
|
||||||
|
})(),
|
||||||
|
args: {},
|
||||||
|
hash: ""
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
t.plan(cases.length);
|
||||||
|
|
||||||
|
var c, obj;
|
||||||
|
for(var i=0; i<cases.length; ++i) {
|
||||||
|
c = cases[i];
|
||||||
|
obj = OpenLayers.Util.createUrlObject(c.url, c.opt);
|
||||||
|
t.eq(obj, c.exp, i + ": '" + c.url + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function test_Util_createUniqueIDSeq(t) {
|
function test_Util_createUniqueIDSeq(t) {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user