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

@ -520,7 +520,9 @@ var HTTPObject = function(engine) {
this.setVariables = function(variables) { this.setVariables = function(variables) {
try { try {
var variables = (typeof(variables) !== "undefined") ? variables : {}; 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) { } catch (e) {
console.error("HTTPObject.setVariables() -> ", e.message); console.error("HTTPObject.setVariables() -> ", e.message);
} }
@ -528,12 +530,12 @@ var HTTPObject = function(engine) {
}; };
this.evaluate = function(str) { this.evaluate = function(str) {
var str = String(str); var str = String(str);
var Lpos = str.indexOf('{'); var Lpos = str.indexOf('{');
var Rpos = str.indexOf('}', Lpos + 1); var Rpos = str.indexOf('}', Lpos + 1);
var s1 = [], s2 = null, s3, s4; var s1 = [], s2 = null, s3, s4;
console.log("Before evaluated:", str); console.log("Before evaluated:", str);
while (Lpos > -1 && Rpos > -1) { while (Lpos > -1 && Rpos > -1) {
s1 = str.substring(Lpos + 1, Rpos).split(' '); s1 = str.substring(Lpos + 1, Rpos).split(' ');
@ -541,8 +543,6 @@ var HTTPObject = function(engine) {
while (s1.length > 0) { while (s1.length > 0) {
s3 = s1.pop(); s3 = s1.pop();
console.log("*", s3);
if (s3 in this.variables) { if (s3 in this.variables) {
switch (typeof(this.variables[s3])) { switch (typeof(this.variables[s3])) {
case "function": case "function":
@ -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('{'); Lpos = str.indexOf('{');
Rpos = str.indexOf('}', Lpos + 1); Rpos = str.indexOf('}', Lpos + 1);
} }
console.log("After evaluated:", str); console.log("After evaluated:", str);
return str; return str;
}; };