Skip to content

Commit

Permalink
fix: remove unnecessary URL allocation (#2554)
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister authored Jun 27, 2024
1 parent bfb5753 commit 138d4c4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export class App<State> {
const { params, handlers } = matched;
const ctx = new FreshReqContext<State>(
req,
url,
conn,
params,
this.config,
Expand Down
3 changes: 2 additions & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,15 @@ export class FreshReqContext<State>

constructor(
req: Request,
url: URL,
info: Deno.ServeHandlerInfo | Deno.ServeUnixHandlerInfo,
params: Record<string, string>,
config: ResolvedFreshConfig,
next: FreshContext<State>["next"],
islandRegistry: ServerIslandRegistry,
buildCache: BuildCache,
) {
this.url = new URL(req.url);
this.url = url;
this.req = req;
this.info = info;
this.params = params;
Expand Down
1 change: 1 addition & 0 deletions src/test_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export function serveMiddleware<T>(

const ctx = new FreshReqContext<T>(
req,
new URL(req.url),
DEFAULT_CONN_INFO,
{},
config,
Expand Down
3 changes: 1 addition & 2 deletions www/routes/thanks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
},
Expand Down

0 comments on commit 138d4c4

Please sign in to comment.