Browse Source

fix: Fix error with deep links trying to parse empty query parameters.

pull/142/head
Trent Larson 3 days ago
parent
commit
e0b9481be5
  1. 1
      src/interfaces/deepLinks.ts
  2. 7
      src/services/deepLinks.ts

1
src/interfaces/deepLinks.ts

@ -33,7 +33,6 @@ export const deepLinkSchemas = {
id: z.string(), id: z.string(),
}), }),
"claim-add-raw": z.object({ "claim-add-raw": z.object({
id: z.string(),
claim: z.string().optional(), claim: z.string().optional(),
claimJwtId: z.string().optional(), claimJwtId: z.string().optional(),
}), }),

7
src/services/deepLinks.ts

@ -201,10 +201,9 @@ export class DeepLinkHandler {
// Continue with parameter validation as before... // Continue with parameter validation as before...
const schema = deepLinkSchemas[path as keyof typeof deepLinkSchemas]; const schema = deepLinkSchemas[path as keyof typeof deepLinkSchemas];
let validatedParams, validatedQuery; let validatedParams;
try { try {
validatedParams = await schema.parseAsync(params); validatedParams = await schema.parseAsync(params);
validatedQuery = await schema.parseAsync(query);
} catch (error) { } catch (error) {
// For parameter validation errors, provide specific error feedback // For parameter validation errors, provide specific error feedback
logConsoleAndDb( logConsoleAndDb(
@ -230,11 +229,10 @@ export class DeepLinkHandler {
await this.router.replace({ await this.router.replace({
name: routeName, name: routeName,
params: validatedParams, params: validatedParams,
query: validatedQuery,
}); });
} catch (error) { } catch (error) {
logConsoleAndDb( logConsoleAndDb(
`[DeepLink] Error routing to route name ${routeName} for path: ${path}: ${JSON.stringify(error)} ... with validated params: ${JSON.stringify(validatedParams)} ... and validated query: ${JSON.stringify(validatedQuery)}`, `[DeepLink] Error routing to route name ${routeName} for path: ${path}: ${JSON.stringify(error)} ... with validated params: ${JSON.stringify(validatedParams)}`,
true, true,
); );
// For parameter validation errors, provide specific error feedback // For parameter validation errors, provide specific error feedback
@ -245,7 +243,6 @@ export class DeepLinkHandler {
originalPath: path, originalPath: path,
errorCode: "ROUTING_ERROR", errorCode: "ROUTING_ERROR",
errorMessage: `Error routing to ${routeName}: ${JSON.stringify(error)}`, errorMessage: `Error routing to ${routeName}: ${JSON.stringify(error)}`,
...validatedQuery,
}, },
}); });
} }

Loading…
Cancel
Save