From e6d6f62627fb36e84c12ba0f40beec1d6e3e657b Mon Sep 17 00:00:00 2001 From: Ndricim Rrapi Date: Fri, 6 May 2022 12:03:08 +0200 Subject: [PATCH] Fix empty nodeParams on browser back navigation (#2692) --- core/src/services/routing.js | 3 ++- core/test/services/routing.spec.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/src/services/routing.js b/core/src/services/routing.js index e59edb1b2d..8497f370b7 100644 --- a/core/src/services/routing.js +++ b/core/src/services/routing.js @@ -128,7 +128,8 @@ class RoutingClass { const intentPath = RoutingHelpers.getIntentPath(hash); return intentPath ? intentPath : '/'; } - const path = (window.history.state && window.history.state.path) || window.location.pathname; + const params = window.location.search ? window.location.search : ''; + const path = (window.history.state && window.history.state.path) || window.location.pathname + params; return path .split('/') .slice(1) diff --git a/core/test/services/routing.spec.js b/core/test/services/routing.spec.js index 40cf4d93f0..6df6310a4a 100644 --- a/core/test/services/routing.spec.js +++ b/core/test/services/routing.spec.js @@ -837,6 +837,16 @@ describe('Routing', function() { assert.equal(Routing.getModifiedPathname(), mockPathName); }); + it('without state and with query params', () => { + const mockPathName = 'projects?~test=param'; + sinon.stub(window.history, 'state').returns(null); + sinon.stub(window, 'location').value({ + pathname: '/projects', + search: '?~test=param' + }); + assert.equal(Routing.getModifiedPathname(), mockPathName); + }); + it('with state path', () => { sinon.stub(window.history, 'state').value({ path: '/this/is/some/'