Update http.js

This commit is contained in:
Namhyeon Go 2022-01-18 00:46:47 +09:00 committed by GitHub
parent ba743ffbbe
commit 344eb14f02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
};