{"record":{"id":"732a1ebc8881141d","repo":"vuejs/vue-router","slug":"duplicate-param-keys-in-route-with-path-path","errorCode":null,"errorMessage":"Duplicate param keys in route with path: \"${path}\"","messagePattern":"Duplicate param keys in route with path: \"(.+?)\"","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/create-route-map.js","lineNumber":201,"sourceCode":"    } else if (process.env.NODE_ENV !== 'production' && !matchAs) {\n      warn(\n        false,\n        `Duplicate named routes definition: ` +\n          `{ name: \"${name}\", path: \"${record.path}\" }`\n      )\n    }\n  }\n}\n\nfunction compileRouteRegex (\n  path: string,\n  pathToRegexpOptions: PathToRegexpOptions\n): RouteRegExp {\n  const regex = Regexp(path, [], pathToRegexpOptions)\n  if (process.env.NODE_ENV !== 'production') {\n    const keys: any = Object.create(null)\n    regex.keys.forEach(key => {\n      warn(\n        !keys[key.name],\n        `Duplicate param keys in route with path: \"${path}\"`\n      )\n      keys[key.name] = true\n    })\n  }\n  return regex\n}\n\nfunction normalizePath (\n  path: string,\n  parent?: RouteRecord,\n  strict?: boolean\n): string {\n  if (!strict) path = path.replace(/\\/$/, '')\n  if (path[0] === '/') return path\n  if (parent == null) return path\n  return cleanPath(`${parent.path}/${path}`)","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/vuejs/vue-router/blob/680ccc68c506cca9be6207745043245d61fa715a/src/create-route-map.js#L183-L219","documentation":"A route path declares the same param name more than once (e.g. '/:id/:id'), producing duplicate keys in the compiled regex. The param value would be overwritten ambiguously, so vue-router warns during path-to-regexp compilation in dev.","triggerScenarios":"Paths like '/:id/:id', '/user/:id/posts/:id', or repeated optional params '/:a?/:a?' where key.name collides in regex.keys.","commonSituations":"Copy-paste of path segments; template-string path builders that interpolate the same param twice; renaming params in one place but not another.","solutions":["Give each param a unique name: '/user/:userId/posts/:postId'","Inspect the generated path string if paths are built dynamically","Refactor so the same value is not captured twice (use one segment or a query param)","Test path matching after renaming params to update this.$route.params consumers"],"exampleFix":"// before\n{ path: '/user/:id/posts/:id' }\n// after\n{ path: '/user/:userId/posts/:postId' }","handlingStrategy":"validation","validationCode":"function assertUniqueParams(path) {\n  const names = (path.match(/:[^/?]+/g) || []).map(s => s.replace(/[^\\w]/g, ''))\n  const dupes = names.filter((n, i) => names.indexOf(n) !== i)\n  if (dupes.length) throw new Error(`Duplicate params ${dupes} in path: ${path}`)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never repeat the same :param name within one path","When building paths from templates, verify interpolated param names differ","Rename this.$route.params consumers after deduplicating params"],"tags":["vue-router","routing","params","path-to-regexp"],"backgroundTag":"duplicate-route-param","analyzedSha":"680ccc68c506cca9be6207745043245d61fa715a","analyzedAt":"2026-09-02T19:19:01.204Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}