cloudflare-esi
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -126,2 +126,16 @@ import { tagParser } from "./tagParser"; | ||
/** | ||
* Converts a string to a number if it is | ||
* passes that to the tester and returns the result | ||
* | ||
* @param {string} str conditional string to split | ||
* @returns {string | number} condition result | ||
*/ | ||
function strToNumOrStr(str) { | ||
// we have to check varInTag is *actually* a number and doesn't just have leading numbers in it | ||
if (strIsNumber(str)) { | ||
return parseInt(str, 10); | ||
} | ||
return str; | ||
} | ||
/** | ||
* Takes a condition string and splits it into its two sides and operator | ||
@@ -146,5 +160,5 @@ * passes that to the tester and returns the result | ||
} | ||
const left = tokensSplit[1] || tokensSplit[2]; | ||
const left = strToNumOrStr(tokensSplit[1] || tokensSplit[2]); | ||
const op = op_replacements[tokensSplit[3]] || tokensSplit[3]; | ||
const right = tokensSplit[4] || tokensSplit[5]; | ||
const right = strToNumOrStr(tokensSplit[4] || tokensSplit[5]); | ||
return esiConditionTester(left, right, op); | ||
@@ -177,2 +191,4 @@ } | ||
case "=~": { | ||
left = left.toString(); | ||
right = right.toString(); | ||
const regex = right.match(regexExtractor); | ||
@@ -179,0 +195,0 @@ if (!regex) |
{ | ||
"name": "cloudflare-esi", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"repository": "cdloh/cloudflare-esi", | ||
@@ -5,0 +5,0 @@ "description": "ESI Parser built to run in Cloudflare workers", |
Sorry, the diff of this file is not supported yet
106394
1520