Skip to content

Commit

Permalink
Fix empty nodeParams on browser back navigation (SAP#2692)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndricimrr authored May 6, 2022
1 parent 5ac37a6 commit e6d6f62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/services/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions core/test/services/routing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
Expand Down

0 comments on commit e6d6f62

Please sign in to comment.