diff --git a/src/defineRoute.ts b/src/defineRoute.ts index 2cda12a9..c93a2ed7 100644 --- a/src/defineRoute.ts +++ b/src/defineRoute.ts @@ -51,7 +51,7 @@ export function defineRoute(...args: any[]): UmbrellaRouteDef { }, (x) => { const parentPathArray = asArray( - parent.path(filter(extensionParamNames)) + parent.path(filter(parentParamNames)) ); const childPathArray = asArray(path(filter(extensionParamNames))); diff --git a/test/defineRoute.test.ts b/test/defineRoute.test.ts index 9fe984ba..43831322 100644 --- a/test/defineRoute.test.ts +++ b/test/defineRoute.test.ts @@ -33,4 +33,24 @@ describe("defineRoute", () => { "b", ]); }); + + it("extending routes with params should merge path", () => { + const fooRoute = defineRoute( + { a: param.path.string }, + (p) => `/foo/${p.a}` + ); + const barRoute = fooRoute.extend( + { b: param.path.string }, + (p) => `/bar/${p.b}` + ); + + expect(Object.keys(barRoute["~internal"].params).sort()).toEqual([ + "a", + "b", + ]); + + expect(barRoute["~internal"].path({ a: "aa", b: "bb" })).toEqual([ + "/foo/aa/bar/bb", + ]); + }); });