fix(meta-handler): update URL handling in injectMetaHandler to include search parameters
- Refactored the URL parsing logic to create a new URL object for better handling of pathname and search parameters. - Added searchParams to the handler's parameters for improved data accessibility. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
parent
8f37d441f2
commit
b833864c9c
|
|
@ -46,13 +46,13 @@ export async function injectMetaHandler(
|
|||
|
||||
for (const [pattern, handler] of Object.entries(importer)) {
|
||||
const matchFn = match(pattern, { decode: decodeURIComponent })
|
||||
const result = matchFn(url)
|
||||
const parsedUrl = new URL(url, upstreamOrigin)
|
||||
const result = matchFn(parsedUrl.pathname)
|
||||
|
||||
if (result) {
|
||||
const parsedUrl = new URL(url, upstreamOrigin)
|
||||
|
||||
return (await handler({
|
||||
params: result.params as Record<string, string>,
|
||||
searchParams: parsedUrl.searchParams,
|
||||
url: parsedUrl,
|
||||
req,
|
||||
apiClient,
|
||||
|
|
@ -79,6 +79,7 @@ export function defineMetadata<Params extends Record<string, string>, T extends
|
|||
url: URL
|
||||
params: Params
|
||||
apiClient: ApiClient
|
||||
searchParams: URLSearchParams
|
||||
origin: string
|
||||
setStatus: (status: number) => void
|
||||
setStatusText: (statusText: string) => void
|
||||
|
|
|
|||
Loading…
Reference in New Issue