From ecbbcd9d7ae62bdf6e0dc7b542046b1923302dfc Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Fri, 29 Aug 2025 15:55:39 +0200 Subject: [PATCH] chore: docs --- .../route-resolver/matchers/matcher-pattern-query.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/router/src/experimental/route-resolver/matchers/matcher-pattern-query.ts b/packages/router/src/experimental/route-resolver/matchers/matcher-pattern-query.ts index 559b6795..a5a09b6b 100644 --- a/packages/router/src/experimental/route-resolver/matchers/matcher-pattern-query.ts +++ b/packages/router/src/experimental/route-resolver/matchers/matcher-pattern-query.ts @@ -60,16 +60,19 @@ export class MatcherPatternQueryParam valueBeforeParse ) as T } catch (error) { + // if there is a miss but we have a default, use it + // otherwise rethrow the error if (this.defaultValue === undefined) { throw error } + // ensure the default value is used value = undefined } } } else { try { value = - // non existing query param should falll back to defaultValue + // non existing query param should fall back to defaultValue valueBeforeParse === undefined ? valueBeforeParse : ((this.parser.get ?? PARAM_PARSER_DEFAULTS.get)( @@ -83,6 +86,8 @@ export class MatcherPatternQueryParam } // miss if there is no default and there was no value in the query + // otherwise, use the default value. This allows parsers to return undefined + // when they want to possibly fallback to the default value if (value === undefined) { if (this.defaultValue === undefined) { throw miss() -- 2.47.3