From 0bfec2aa36c3bbfac8ed0adb5db6fbf84fb38f8f Mon Sep 17 00:00:00 2001 From: erKam <88717125+erkamyaman@users.noreply.github.com> Date: Sun, 11 Oct 2026 06:20:08 +0300 Subject: [PATCH] fix(router): match the current URL when probing it The probe action navigates with skipLocationChange and the router's default onSameUrlNavigation 'ignore'. For the URL the app is already on, Angular emits NavigationSkipped before recognizing routes, so the probe answered matched: false with an "ignored" reason, which reads as "no route matches this URL". The probe now passes onSameUrlNavigation 'reload', so the current URL is recognized; the probe still stops right after recognition and the URL stays the same. --- packages/devtools/src/__tests__/router-features.test.ts | 4 ++-- packages/devtools/src/router-actions.ts | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/devtools/src/__tests__/router-features.test.ts b/packages/devtools/src/__tests__/router-features.test.ts index e99fd02b..23949361 100644 --- a/packages/devtools/src/__tests__/router-features.test.ts +++ b/packages/devtools/src/__tests__/router-features.test.ts @@ -287,7 +287,7 @@ describe('router features on a real Router', () => { ); it.skipIf(!angularAtLeast('20.2.0'))( - 'reports the skip when probing the URL the router is already on', + 'matches the URL the router is already on instead of reporting a skip', async () => { await router.navigateByUrl('/users/8'); vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] }); @@ -301,7 +301,7 @@ describe('router features on a real Router', () => { await vi.advanceTimersByTimeAsync(10_000); const result = (await pending) as Record; expect(result['error']).toBeUndefined(); - expect(result).toMatchObject({ matched: false, reason: expect.stringMatching(/ignored/) }); + expect(result).toMatchObject({ matched: true }); expect(router.url).toBe('/users/8'); } finally { vi.useRealTimers(); diff --git a/packages/devtools/src/router-actions.ts b/packages/devtools/src/router-actions.ts index 475f7457..2049a1ab 100644 --- a/packages/devtools/src/router-actions.ts +++ b/packages/devtools/src/router-actions.ts @@ -742,8 +742,13 @@ function probe(router: AnyRecord, navigations: NavigationRecord[], url: string): const current = navigationIdOf(router); targetId = current < 0 ? current : current + 1; setCaller('probe from DevTools', true); + // 'reload' so probing the current URL is matched instead of skipped as the same URL. const promise = read( - () => router['navigateByUrl'](url, { skipLocationChange: true }) as Promise, + () => + router['navigateByUrl'](url, { + skipLocationChange: true, + onSameUrlNavigation: 'reload', + }) as Promise, null, ); promise?.catch?.(() => {});