Skip to content

Commit

Permalink
src: temporary fix for substitution middleware (#157)
Browse files Browse the repository at this point in the history
Signed-off-by: flakey5 <[email protected]>
  • Loading branch information
flakey5 authored Oct 31, 2024
1 parent d657385 commit 1a2512a
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/middleware/subtituteMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ export class SubtitutionMiddleware implements Middleware {
this.replaceValue = replaceValue;
}

handle(request: Request, ctx: Context): Promise<Response> {
request.unsubtitutedUrl = request.urlObj;

// router will take care of setting request.urlObj
Object.assign(request, {
...request,
url: request.url.replaceAll(this.searchValue, this.replaceValue),
});

return this.router.handle(request, ctx);
handle(request: Request, _: Context): Promise<Response> {
// todo fix this
return Promise.resolve(
Response.redirect(
request.url.replaceAll(this.searchValue, this.replaceValue)
)
);
}
}

0 comments on commit 1a2512a

Please sign in to comment.