From 1372b3714f5f6efd6e85d4f0a4f109b944d1df0c Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Tue, 28 Jan 2025 12:09:57 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20re-write=20form=20actions=20to?= =?UTF-8?q?=20be=20properly=20based?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When proxying the Effection site, there is a form action like: ```html
``` This broke because that url does not exist This changes all form actions to also be rebased. --- routes/proxy-route.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/routes/proxy-route.ts b/routes/proxy-route.ts index 1ba7eb69..31109545 100644 --- a/routes/proxy-route.ts +++ b/routes/proxy-route.ts @@ -60,7 +60,7 @@ export function proxyRoute(options: ProxyRouteOptions): HTTPMiddleware { let body = yield* call(() => response.text()); let tree = fromHtml(body); - let elements = selectAll('[href^="/"],[src^="/"]', tree); + let elements = selectAll('[href^="/"],[src^="/"],form[action]', tree); for (let element of elements) { let properties = element.properties!; @@ -73,6 +73,11 @@ export function proxyRoute(options: ProxyRouteOptions): HTTPMiddleware { if (properties.src) { properties.src = posixNormalize(`${base.pathname}${properties.src}`); } + if (properties.action) { + properties.action = posixNormalize( + `${base.pathname}${properties.action}`, + ); + } } let headers: Record = {}; for (let [key, value] of response.headers.entries()) {