fix: remove unnecessary URL allocation (#2554)
This commit is contained in:
@@ -203,6 +203,7 @@ export class App<State> {
|
|||||||
const { params, handlers } = matched;
|
const { params, handlers } = matched;
|
||||||
const ctx = new FreshReqContext<State>(
|
const ctx = new FreshReqContext<State>(
|
||||||
req,
|
req,
|
||||||
|
url,
|
||||||
conn,
|
conn,
|
||||||
params,
|
params,
|
||||||
this.config,
|
this.config,
|
||||||
|
|||||||
+2
-1
@@ -111,6 +111,7 @@ export class FreshReqContext<State>
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
req: Request,
|
req: Request,
|
||||||
|
url: URL,
|
||||||
info: Deno.ServeHandlerInfo | Deno.ServeUnixHandlerInfo,
|
info: Deno.ServeHandlerInfo | Deno.ServeUnixHandlerInfo,
|
||||||
params: Record<string, string>,
|
params: Record<string, string>,
|
||||||
config: ResolvedFreshConfig,
|
config: ResolvedFreshConfig,
|
||||||
@@ -118,7 +119,7 @@ export class FreshReqContext<State>
|
|||||||
islandRegistry: ServerIslandRegistry,
|
islandRegistry: ServerIslandRegistry,
|
||||||
buildCache: BuildCache,
|
buildCache: BuildCache,
|
||||||
) {
|
) {
|
||||||
this.url = new URL(req.url);
|
this.url = url;
|
||||||
this.req = req;
|
this.req = req;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ export function serveMiddleware<T>(
|
|||||||
|
|
||||||
const ctx = new FreshReqContext<T>(
|
const ctx = new FreshReqContext<T>(
|
||||||
req,
|
req,
|
||||||
|
new URL(req.url),
|
||||||
DEFAULT_CONN_INFO,
|
DEFAULT_CONN_INFO,
|
||||||
{},
|
{},
|
||||||
config,
|
config,
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import { define } from "../utils/state.ts";
|
|||||||
|
|
||||||
export const handler = define.handlers({
|
export const handler = define.handlers({
|
||||||
GET(ctx) {
|
GET(ctx) {
|
||||||
const url = new URL(ctx.req.url);
|
const search = new URLSearchParams(ctx.url.search);
|
||||||
const search = new URLSearchParams(url.search);
|
|
||||||
const vote = search.get("vote");
|
const vote = search.get("vote");
|
||||||
return page({ vote });
|
return page({ vote });
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user