mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-12 04:31:04 +00:00
Update URL expression (e.g. http://domain/:a/:b)
This commit is contained in:
parent
966f554d0f
commit
3997be2baf
20
lib/http.js
20
lib/http.js
|
@ -216,6 +216,8 @@ var HTTPObject = function() {
|
||||||
// Type 1: http://domain?a=1&b=2&c=3
|
// Type 1: http://domain?a=1&b=2&c=3
|
||||||
// Type 2: http://domain/:a/:b/:c
|
// Type 2: http://domain/:a/:b/:c
|
||||||
this.serializeParameters = function(url) {
|
this.serializeParameters = function(url) {
|
||||||
|
console.log(Object.keys(this.parameters).join(","));
|
||||||
|
|
||||||
if (Object.keys(this.parameters).length > 0) {
|
if (Object.keys(this.parameters).length > 0) {
|
||||||
// Type 2
|
// Type 2
|
||||||
var parameters = {};
|
var parameters = {};
|
||||||
|
@ -228,14 +230,18 @@ var HTTPObject = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type 1
|
// Type 1
|
||||||
if (url.indexOf('?') > -1) {
|
if (Object.keys(parameters).length > 0) {
|
||||||
return url + '&' + this.serializeURL(parameters);
|
if (url.indexOf('?') > -1) {
|
||||||
} else {
|
url += '&' + this.serializeURL(parameters);
|
||||||
return url + '?' + this.serializeURL(parameters);
|
} else {
|
||||||
|
url += '?' + this.serializeURL(parameters);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("Requested URL: " + url);
|
||||||
|
|
||||||
|
return url;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.open = function(method, url) {
|
this.open = function(method, url) {
|
||||||
|
@ -286,6 +292,8 @@ var HTTPObject = function() {
|
||||||
sleep(100);
|
sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("ResponseText: " + this.interface.responseText);
|
||||||
|
|
||||||
if (this.isJSONResponse()) {
|
if (this.isJSONResponse()) {
|
||||||
if (typeof(WScript) !== "undefined") {
|
if (typeof(WScript) !== "undefined") {
|
||||||
JSON = {};
|
JSON = {};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user