Skip to content

Commit

Permalink
Updated cms_path with page querystring (#5822)
Browse files Browse the repository at this point in the history
  • Loading branch information
vxsx authored and czpython committed Dec 27, 2016
1 parent 4b8089b commit 865087b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cms/static/cms/js/dist/3.4.1/bundle.admin.base.min.js

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions cms/static/cms/js/dist/3.4.1/bundle.toolbar.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion cms/static/cms/js/modules/cms.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ CMS.API.Helpers = {
* @returns {String} modified url
*/
updateUrlWithPath: function (url) {
var path = window.location.pathname;
var win = this._getWindow();
var path = win.location.pathname + win.location.search;

return this.makeURL(url, ['cms_path=' + encodeURIComponent(path)]);
}
Expand Down
14 changes: 14 additions & 0 deletions cms/tests/frontend/unit/cms.base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1102,5 +1102,19 @@ describe('cms.base.js', function () {
expect(CMS.API.Helpers._getWindow()).toEqual(window);
});
});

describe('.updateUrlWithPath()', function () {
it('supports query strings', function () {
spyOn(CMS.API.Helpers, '_getWindow').and.returnValue({
location: {
pathname: '/de/',
search: '?language=en'
}
});

expect(CMS.API.Helpers.updateUrlWithPath('/'))
.toEqual('/?cms_path=%2Fde%2F%3Flanguage%3Den');
});
});
});
});
4 changes: 3 additions & 1 deletion cms/tests/frontend/unit/cms.toolbar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,9 @@ describe('CMS.Toolbar', function () {
});
fakeWindow = {
location: {
href: ''
href: '',
pathname: '/context.html',
search: ''
}
};
spyOn(CMS.Navigation.prototype, 'initialize').and.callFake(function () {
Expand Down

0 comments on commit 865087b

Please sign in to comment.