From 2770943807f51598215ad4e253ee6e54c9f91d69 Mon Sep 17 00:00:00 2001 From: flakey5 <73616808+flakey5@users.noreply.github.com> Date: Mon, 21 Aug 2023 21:11:44 -0700 Subject: [PATCH] Don't parse url until it's needed (#36) --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 5485997..205ea00 100644 --- a/src/index.ts +++ b/src/index.ts @@ -148,7 +148,6 @@ export default { let triedIndex = false; - const url = new URL(request.url); let response: Response | undefined; const isCachingEnabled = env.CACHE_CONTROL !== "no-store" @@ -162,6 +161,7 @@ export default { if (!response || !(response.ok || response.status == 304)) { console.warn("Cache miss"); + const url = new URL(request.url); let path = (env.PATH_PREFIX || "") + decodeURIComponent(url.pathname); // directory logic