mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-03-12 00:45:14 +00:00
Update http.js
This commit is contained in:
parent
ba743ffbbe
commit
344eb14f02
16
lib/http.js
16
lib/http.js
|
@ -516,11 +516,13 @@ var HTTPObject = function(engine) {
|
|||
this.setVariable = function(k, v) {
|
||||
this.variables[k] = v;
|
||||
};
|
||||
|
||||
|
||||
this.setVariables = function(variables) {
|
||||
try {
|
||||
var variables = (typeof(variables) !== "undefined") ? variables : {};
|
||||
for (var k in variables) this.setVariable(k, variables[k]);
|
||||
for (var k in variables)
|
||||
this.setVariable(k, variables[k])
|
||||
;
|
||||
} catch (e) {
|
||||
console.error("HTTPObject.setVariables() -> ", e.message);
|
||||
}
|
||||
|
@ -528,20 +530,18 @@ var HTTPObject = function(engine) {
|
|||
};
|
||||
|
||||
this.evaluate = function(str) {
|
||||
var str = String(str);
|
||||
var str = String(str);
|
||||
var Lpos = str.indexOf('{');
|
||||
var Rpos = str.indexOf('}', Lpos + 1);
|
||||
var s1 = [], s2 = null, s3, s4;
|
||||
|
||||
console.log("Before evaluated:", str);
|
||||
console.log("Before evaluated:", str);
|
||||
|
||||
while (Lpos > -1 && Rpos > -1) {
|
||||
s1 = str.substring(Lpos + 1, Rpos).split(' ');
|
||||
|
||||
while (s1.length > 0) {
|
||||
s3 = s1.pop();
|
||||
|
||||
console.log("*", s3);
|
||||
|
||||
if (s3 in this.variables) {
|
||||
switch (typeof(this.variables[s3])) {
|
||||
|
@ -561,12 +561,12 @@ var HTTPObject = function(engine) {
|
|||
}
|
||||
}
|
||||
|
||||
str = str.substring(0, Lpos) + s2 + str.substring(Rpos + 1);
|
||||
str = str.substring(0, Lpos) + s2 + str.substring(Rpos + 1);
|
||||
Lpos = str.indexOf('{');
|
||||
Rpos = str.indexOf('}', Lpos + 1);
|
||||
}
|
||||
|
||||
console.log("After evaluated:", str);
|
||||
console.log("After evaluated:", str);
|
||||
|
||||
return str;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user