diff --git a/src/app/tests/app-routing.module.test.ts b/src/app/app-routing.module.test.ts similarity index 94% rename from src/app/tests/app-routing.module.test.ts rename to src/app/app-routing.module.test.ts index 843ccb3a5..fc06216b9 100644 --- a/src/app/tests/app-routing.module.test.ts +++ b/src/app/app-routing.module.test.ts @@ -17,7 +17,7 @@ import { UrlSegment, UrlSegmentGroup } from '@angular/router'; import { mock } from '@/testing/utils'; -import { buildRegExpUrlMatcher } from '../app-routing.module'; +import { buildRegExpUrlMatcher } from './app-routing.module'; describe('Routing utils', () => { @@ -35,6 +35,7 @@ describe('Routing utils', () => { ); testMatcher('baz/foo/bar', null); + testMatcher('foobar', null); testMatcher('foo', ['foo']); testMatcher('foo/baz', ['foo']); testMatcher('foo/bar/bar/baz', ['foo', 'bar', 'bar']); diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 4d833851f..3704e74c3 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -113,14 +113,18 @@ export function buildRegExpUrlMatcher(regexp: RegExp): UrlMatcher { } // Consume segments that match. - const [consumed] = segments.slice(1).reduce(([consumed, path], segment) => path === match - ? [consumed, path] - :[ - consumed.concat(segment), + const [consumedSegments, consumedPath] = segments.slice(1).reduce(([segments, path], segment) => path === match + ? [segments, path] + : [ + segments.concat(segment), `${path}/${segment.path}`, ], [[segments[0]] as UrlSegment[], segments[0].path]); - return { consumed }; + if (consumedPath !== match) { + return null; + } + + return { consumed: consumedSegments }; }; }