From ea7c26d00c8a3d253355a0bd3206b71aee041199 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 3 Nov 2021 16:55:46 +0100 Subject: [PATCH] [Share] The redirect app path should not appear in the browser history (#117155) (#117310) * the redirect app path should not appear in the browser history * updated jest test to also expect replace * added comment * update jest test --- .../redirect/redirect_manager.test.ts | 18 ++++++++++++------ .../url_service/redirect/redirect_manager.ts | 4 +++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/plugins/share/public/url_service/redirect/redirect_manager.test.ts b/src/plugins/share/public/url_service/redirect/redirect_manager.test.ts index 7296ef6d0c137..1fde60d4389fa 100644 --- a/src/plugins/share/public/url_service/redirect/redirect_manager.test.ts +++ b/src/plugins/share/public/url_service/redirect/redirect_manager.test.ts @@ -57,9 +57,12 @@ describe('on page mount', () => { }) )}` ); - expect(spy).toHaveBeenCalledWith({ - foo: 'bar', - }); + expect(spy).toHaveBeenCalledWith( + { + foo: 'bar', + }, + { replace: true } + ); }); test('migrates parameters on-the-fly to the latest version', async () => { @@ -73,9 +76,12 @@ describe('on page mount', () => { }) )}` ); - expect(spy).toHaveBeenCalledWith({ - num: 2, - }); + expect(spy).toHaveBeenCalledWith( + { + num: 2, + }, + { replace: true } + ); }); test('throws if locator does not exist', async () => { diff --git a/src/plugins/share/public/url_service/redirect/redirect_manager.ts b/src/plugins/share/public/url_service/redirect/redirect_manager.ts index 810977659bcf0..e6f524347e48c 100644 --- a/src/plugins/share/public/url_service/redirect/redirect_manager.ts +++ b/src/plugins/share/public/url_service/redirect/redirect_manager.ts @@ -66,7 +66,9 @@ export class RedirectManager { }); locator - .navigate(migratedParams) + .navigate(migratedParams, { + replace: true, // We do not want the redirect app URL to appear in browser navigation history + }) .then() .catch((error) => { // eslint-disable-next-line no-console