diff --git a/src/apps/deployable-app-module.ts b/src/apps/deployable-app-module.ts index d25f93b5..c9fa5197 100644 --- a/src/apps/deployable-app-module.ts +++ b/src/apps/deployable-app-module.ts @@ -112,8 +112,13 @@ function assertFeatureRoutesReachOwningContext( `A feature replaces a platform route only by declaring its id (${FEATURE_REPLACEABLE_PLATFORM_ROUTE_IDS.join(", ")}).`, ); } - // Parameter names do not change how the router ranks a path. - const shape = path.replace(/:[^/]+/g, ":"); + // Parameter names do not change how the router ranks a path, and + // (1103/08-04) neither do letter case or a trailing slash: the router + // matches case-insensitively and ignores the slash. + const shape = path + .replace(/:[^/]+/g, ":") + .toLowerCase() + .replace(/\/+$/, ""); const earlier = claimed.get(shape); if (earlier !== undefined) { throw new TypeError( diff --git a/tests/architecture/context-route-roots.test.ts b/tests/architecture/context-route-roots.test.ts index 50b0c8b1..fceb7a32 100644 --- a/tests/architecture/context-route-roots.test.ts +++ b/tests/architecture/context-route-roots.test.ts @@ -223,6 +223,33 @@ describe("feature routes and platform routes", () => { ).toThrow(/ITEM_DETAIL.*\/shop\/items\/:itemId.*items.*ORDER_DETAIL.*orders/); }); + it.each< + Readonly<{ + differ: string; + first: Readonly>; + second: Readonly>; + }> + >([ + { + differ: "only by letter case", + first: { ITEM_DETAIL: "/shop/items/:itemId" }, + second: { OTHER_ITEM_DETAIL: "/shop/Items/:id" }, + }, + { + differ: "only by a trailing slash", + first: { ITEM_LIST: "/shop/items" }, + second: { OTHER_ITEM_LIST: "/shop/items/" }, + }, + ])("rejects two feature routes whose paths differ $differ", ({ first, second }) => { + // 1103/08-04. The router matches paths case-insensitively and ignores a + // trailing slash, so these tie like identical paths. + expect(() => + app( + context("shop", "shop/*", [feature("items", first), feature("others", second)]), + ), + ).toThrow(/OTHER_ITEM_.*others.*has the same path as route ITEM_.*items/); + }); + it("accepts a static path next to a parameter at the same depth", () => { expect(() => app(