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