From 8e26e781d43b521116d4787154e0551d4c7d3b50 Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Mon, 20 Feb 2023 09:18:03 -0800 Subject: [PATCH] fix type errors --- src/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 707f7d1..82198d4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -50,9 +50,13 @@ export interface ResolveHTTPRequestOptions { } function getPath (event: H3Event): string | null { - if (typeof event.context.params.trpc === 'string') { return event.context.params.trpc } + const { params } = event.context - if (Array.isArray(event.context.params.trpc)) { return event.context.params.trpc.join('/') } + if (typeof params?.trpc === 'string') { return params.trpc } + + if (params?.trpc && Array.isArray(params.trpc)) { + return (params.trpc as string[]).join('/') + } return null }