cloudflare-esi
Advanced tools
Comparing version 0.0.0-80da88e873fb9fde62ab111b2ef36a72a2bb84fa to 0.0.0-8ffcc577deb65e3f94b84251648ea032b8dd70ad
@@ -93,3 +93,3 @@ /// <reference types="@cloudflare/workers-types" /> | ||
export declare type customESIVarsFunction = (request: Request) => Promise<customESIVars>; | ||
export declare type fetchFunction = (request: string | Request, requestInitr?: Request | RequestInit | undefined) => Promise<Response>; | ||
export declare type fetchFunction = (request: string | Request) => Promise<Response>; | ||
export declare class esi { | ||
@@ -96,0 +96,0 @@ options: ESIConfig; |
@@ -91,3 +91,3 @@ import { tagParser } from "./tagParser"; | ||
const reg_esi_brackets = /(?:'.*?(?<!\\)')|(\(|\))/g; | ||
const reg_esi_condition = /(?:(\d+(?:\.\d+)?)|(?:'(.*?)(?<!\\)'))\s*(!=|={2}|=~|<=|>=|>|<)\s*(?:(\d+(?:\.\d+)?)|(?:'(.*?)(?<!\\)'))/; | ||
const reg_esi_condition = /(?:(\d+(?:\.\d+)?)|(?:'(.*?)(?<!\\)'))\s*(!=|==|=~|<=|>=|>|<)\s*(?:(\d+(?:\.\d+)?)|(?:'(.*?)(?<!\\)'))/; | ||
/** | ||
@@ -254,3 +254,2 @@ * Evaluates esi Vars within when tag conditional statements | ||
let depth = 0; | ||
let conditionAfter = null; | ||
const fullExpression = []; | ||
@@ -280,4 +279,2 @@ const tokensSplit = condition.matchAll(reg_esi_brackets); | ||
fullExpression.push(bracketResult.toString()); | ||
// Grab anything that is left | ||
conditionAfter = condition.substring(endIndex + 1); | ||
// Know were we are up too | ||
@@ -288,10 +285,11 @@ parsedPoint = endIndex + 1; | ||
} | ||
// If we didnt have any then push it all along | ||
// Otherwise push the leftovers and return | ||
if (endIndex == -1) { | ||
fullExpression.push(condition); | ||
return await esi_seperator_splitter(condition); | ||
} | ||
if (conditionAfter) { | ||
fullExpression.push(conditionAfter); | ||
else { | ||
fullExpression.push(condition.substring(endIndex + 1)); | ||
return await esi_seperator_splitter(fullExpression.join("")); | ||
} | ||
const condResult = await esi_seperator_splitter(fullExpression.join("")); | ||
return condResult; | ||
} | ||
@@ -298,0 +296,0 @@ /** |
{ | ||
"name": "cloudflare-esi", | ||
"version": "0.0.0-80da88e873fb9fde62ab111b2ef36a72a2bb84fa", | ||
"version": "0.0.0-8ffcc577deb65e3f94b84251648ea032b8dd70ad", | ||
"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
Sorry, the diff of this file is not supported yet
101607
1477