cloudflare-esi
Advanced tools
Comparing version 0.0.0-b5e6425760f3a3af6bd8e2a323ddd3cecdf082da to 0.0.0-b64faf1b8335e401b8122eba5e4e576fb198f528
@@ -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; |
@@ -27,2 +27,5 @@ import { create as createHandleChunk } from "./handleChunk"; | ||
if (recursion >= limit) { | ||
// We dont have to set the URL value here | ||
// As we're going to get here in a ESI loop | ||
// And the parent value will have a URL set | ||
return new Response(""); | ||
@@ -64,3 +67,6 @@ } | ||
(await canDelegateToSurrogate(origRequest, this.options))) { | ||
return new Response(response.body, response); | ||
const resp = new Response(response.body, response); | ||
// We set the URL manually here as it doesn't come across from the copy˛ | ||
Object.defineProperty(resp, "url", { value: response.url }); | ||
return resp; | ||
} | ||
@@ -72,2 +78,4 @@ const { readable, writable } = new TransformStream(); | ||
const mutResponse = new Response(readable, response); | ||
// We set the URL manually here as it doesn't come across from the copy˛ | ||
Object.defineProperty(mutResponse, "url", { value: response.url }); | ||
// Zero downstream lifetime | ||
@@ -74,0 +82,0 @@ mutResponse.headers.set("Cache-Control", "private, max-age=0"); |
@@ -31,3 +31,3 @@ import { replace_vars } from "./processESIVars"; | ||
// Push anything from before the tag into the response | ||
const before = chunk.substring(retFrom, includeMatch.index); | ||
const before = chunk.substring(0, includeMatch.index); | ||
res.push(evalVars ? replace_vars(eventData, before) : before); | ||
@@ -34,0 +34,0 @@ // Keep the remainder for next chunk |
{ | ||
"name": "cloudflare-esi", | ||
"version": "0.0.0-b5e6425760f3a3af6bd8e2a323ddd3cecdf082da", | ||
"version": "0.0.0-b64faf1b8335e401b8122eba5e4e576fb198f528", | ||
"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
102392
1485