{"version":3,"file":"create-route-request.cjs","sources":["../../../src/router/http/create-route-request.ts"],"sourcesContent":["import { applySearchParams } from './apply-search-params';\n\n/**\n * Creates a new Request object with the same body, headers, and search params as the original.\n *\n * Replaces the URL with the given path, stripping the `.html` extension and `/index.html` for\n * asset matching.\n * https://developers.cloudflare.com/pages/platform/serving-pages/#route-matching\n *\n * @param req Request object to re-create.\n * @param path URL to use for the new Request object.\n * @returns A new Request object with the same body and headers as the original.\n */\nexport const createRouteRequest = (req: Request, path: string): Request => {\n\tconst newUrl = new URL(path, req.url);\n\tapplySearchParams(newUrl.searchParams, new URL(req.url).searchParams);\n\n\tnewUrl.pathname = newUrl.pathname.replace(/\\/index.html$/, '/').replace(/\\.html$/, '');\n\n\treturn new Request(newUrl, req);\n};\n"],"names":["createRouteRequest","req","path","newUrl","applySearchParams"],"mappings":"6HAaaA,EAAqB,CAACC,EAAcC,IAA0B,CAC1E,MAAMC,EAAS,IAAI,IAAID,EAAMD,EAAI,GAAG,EACpCG,OAAAA,oBAAkBD,EAAO,aAAc,IAAI,IAAIF,EAAI,GAAG,EAAE,YAAY,EAE7DE,EAAA,SAAWA,EAAO,SAAS,QAAQ,gBAAiB,GAAG,EAAE,QAAQ,UAAW,EAAE,EAE9E,IAAI,QAAQA,EAAQF,CAAG,CAC/B"}