]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor: leftover
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 8 Aug 2025 20:23:49 +0000 (22:23 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 8 Aug 2025 20:23:49 +0000 (22:23 +0200)
packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts

index 00ce26bdf683b1382fdde41677e6a9d50c6e21c7..e1f21b78a1c974bf4691f9743d4ea7d89e3bb9f8 100644 (file)
@@ -150,12 +150,6 @@ export function defineParamParser<TOut, TIn extends string | string[]>(parser: {
   return parser
 }
 
-interface IdFn {
-  (v: undefined | null): null
-  (v: string): string
-  (v: string[]): string[]
-}
-
 const PATH_PARAM_DEFAULT_GET = (value: string | string[] | null | undefined) =>
   value ?? null
 export const PATH_PARAM_SINGLE_DEFAULT: Param_GetSet<string, string> = {}
@@ -344,52 +338,6 @@ export class MatcherPatternPathCustomParams<
   }
 }
 
-const aaa = new MatcherPatternPathCustomParams(
-  /^\/profiles\/([^/]+)$/i,
-  {
-    userId: {
-      parser: PARAM_INTEGER,
-      // parser: PATH_PARAM_DEFAULT_PARSER,
-    },
-  },
-  ['profiles', 0]
-)
-// @ts-expect-error: not existing param
-aaa.build({ a: '2' })
-// @ts-expect-error: must be a number
-aaa.build({ userId: '2' })
-aaa.build({ userId: 2 })
-// @ts-expect-error: not existing param
-aaa.match('/profiles/2')?.e
-// @ts-expect-error: not existing param
-aaa.match('/profiles/2').e
-aaa.match('/profiles/2').userId.toFixed(2)
-
-// Factory function for better type inference
-export function createMatcherPatternPathCustomParams<
-  TParamsOptions extends Record<
-    string,
-    MatcherPatternPathCustomParamOptions<any, any>
-  >,
->(
-  re: RegExp,
-  params: TParamsOptions,
-  pathParts: Array<string | number>
-): MatcherPatternPathCustomParams<TParamsOptions> {
-  return new MatcherPatternPathCustomParams(re, params, pathParts)
-}
-
-// Now use it like this:
-const aab = createMatcherPatternPathCustomParams(
-  /^\/profiles\/([^/]+)$/i,
-  {
-    userId: {
-      parser: PARAM_INTEGER,
-    },
-  },
-  ['profiles', 0]
-)
-
 /**
  * Matcher for dynamic paths, e.g. `/team/:id/:name`.
  * Supports one, one or zero, one or more and zero or more params.