@cloudflare/pages-plugin-static-forms
Advanced tools
+31
-14
@@ -1,2 +0,2 @@ | ||
| // functions/_middleware.ts | ||
| // _middleware.ts | ||
| var onRequestPost = async ({ | ||
@@ -26,3 +26,6 @@ request, | ||
| form.removeAttribute("action"); | ||
| form.append(`<input type="hidden" name="static-form-name" value="${formName}" />`, { html: true }); | ||
| form.append( | ||
| `<input type="hidden" name="static-form-name" value="${formName}" />`, | ||
| { html: true } | ||
| ); | ||
| } | ||
@@ -32,3 +35,3 @@ }).transform(response); | ||
| // ../../../../../../var/folders/ww/hfjqy4gs3p12j4qfrlf026lr0000gp/T/functionsRoutes.mjs | ||
| // ../../../../../../../var/folders/dr/3c4srmxd26sdx440rq2m50380000gp/T/functionsRoutes-0.6543852041508254.mjs | ||
| var routes = [ | ||
@@ -51,3 +54,3 @@ { | ||
| // ../../node_modules/path-to-regexp/dist.es2015/index.js | ||
| // ../../../node_modules/path-to-regexp/dist.es2015/index.js | ||
| function lexer(str) { | ||
@@ -340,3 +343,4 @@ var tokens = []; | ||
| // ../../node_modules/wrangler/pages/functions/template-plugin.ts | ||
| // ../../../node_modules/wrangler/templates/pages-template-plugin.ts | ||
| var escapeRegex = /[.+?^${}()|[\]\\]/g; | ||
| function* executeRequest(request, relativePathname) { | ||
@@ -347,4 +351,8 @@ for (const route of [...routes].reverse()) { | ||
| } | ||
| const routeMatcher = match(route.routePath, { end: false }); | ||
| const mountMatcher = match(route.mountPath, { end: false }); | ||
| const routeMatcher = match(route.routePath.replace(escapeRegex, "\\$&"), { | ||
| end: false | ||
| }); | ||
| const mountMatcher = match(route.mountPath.replace(escapeRegex, "\\$&"), { | ||
| end: false | ||
| }); | ||
| const matchResult = routeMatcher(relativePathname); | ||
@@ -366,4 +374,8 @@ const mountMatchResult = mountMatcher(relativePathname); | ||
| } | ||
| const routeMatcher = match(route.routePath, { end: true }); | ||
| const mountMatcher = match(route.mountPath, { end: false }); | ||
| const routeMatcher = match(route.routePath.replace(escapeRegex, "\\$&"), { | ||
| end: true | ||
| }); | ||
| const mountMatcher = match(route.mountPath.replace(escapeRegex, "\\$&"), { | ||
| end: false | ||
| }); | ||
| const matchResult = routeMatcher(relativePathname); | ||
@@ -383,3 +395,3 @@ const mountMatchResult = mountMatcher(relativePathname); | ||
| } | ||
| function template_plugin_default(pluginArgs) { | ||
| function pages_template_plugin_default(pluginArgs) { | ||
| const onRequest = async (workerContext) => { | ||
@@ -389,3 +401,3 @@ let { request } = workerContext; | ||
| const url = new URL(request.url); | ||
| const relativePathname = `/${url.pathname.split(workerContext.functionPath)[1] || ""}`.replace(/^\/\//, "/"); | ||
| const relativePathname = `/${url.pathname.replace(workerContext.functionPath, "") || ""}`.replace(/^\/\//, "/"); | ||
| const handlerIterator = executeRequest(request, relativePathname); | ||
@@ -407,6 +419,7 @@ const pluginNext = async (input, init) => { | ||
| env, | ||
| waitUntil: workerContext.waitUntil.bind(workerContext) | ||
| waitUntil: workerContext.waitUntil.bind(workerContext), | ||
| passThroughOnException: workerContext.passThroughOnException.bind(workerContext) | ||
| }; | ||
| const response = await handler(context); | ||
| return new Response([101, 204, 205, 304].includes(response.status) ? null : response.body, { ...response, headers: new Headers(response.headers) }); | ||
| return cloneResponse(response); | ||
| } else { | ||
@@ -420,4 +433,8 @@ return next(); | ||
| } | ||
| var cloneResponse = (response) => new Response( | ||
| [101, 204, 205, 304].includes(response.status) ? null : response.body, | ||
| response | ||
| ); | ||
| export { | ||
| template_plugin_default as default | ||
| pages_template_plugin_default as default | ||
| }; |
+1
-1
| { | ||
| "name": "@cloudflare/pages-plugin-static-forms", | ||
| "version": "1.0.0", | ||
| "version": "1.0.1", | ||
| "main": "index.js", | ||
@@ -5,0 +5,0 @@ "types": "index.d.ts", |
13768
2.71%445
3.97%