8000 fix: do not replace & with & in URLs by nichoski · Pull Request #7115 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

fix: do not replace & with & in URLs #7115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: do not replace & with & in URLs
  • Loading branch information
nichoski committed Aug 19, 2021
commit affda7b148e10611388fa569a73ecede8a769f17
2 changes: 1 addition & 1 deletion cms/static/cms/js/dist/3.7.4/bundle.admin.base.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cms/static/cms/js/dist/3.7.4/bundle.toolbar.min.js

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions cms/static/cms/js/modules/cms.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,7 @@ export const Helpers = {
newUrl.addSearch(key, value);
});

return newUrl
.toString()
.split('#')
.map((part, i) => {
return i === 0 ? part.replace(/&/g, '&') : part;
})
.join('#');
return newUrl.toString();
},

/**
Expand Down
22 changes: 11 additions & 11 deletions cms/tests/frontend/unit/cms.base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,45 +769,45 @@ describe('cms.base.js', function() {
var url;

url = CMS.API.Helpers.makeURL('test', [['param', '1'], ['another', '2']]);
expect(url).toEqual('test?param=1&another=2');
expect(url).toEqual('test?param=1&another=2');

url = CMS.API.Helpers.makeURL('test?param=1', [['another', '2']]);
expect(url).toEqual('test?param=1&another=2');
expect(url).toEqual('test?param=1&another=2');

url = CMS.API.Helpers.makeURL('test?param=1&another=2', [['different', '3']]);
expect(url).toEqual('test?param=1&another=2&different=3');
expect(url).toEqual('test?param=1&another=2&different=3');

url = CMS.API.Helpers.makeURL('test?param=1&another=2', [['different', '3']]);
expect(url).toEqual('test?param=1&another=2&different=3');
expect(url).toEqual('test?param=1&another=2&different=3');

url = CMS.API.Helpers.makeURL('test?param=1&another=2&again=3', [['different', '3']]);
expect(url).toEqual('test?param=1&another=2&again=3&different=3');
expect(url).toEqual('test?param=1&another=2&again=3&different=3');
});

it('replaces param values with new ones if they match', function() {
var url;

url = CMS.API.Helpers.makeURL('test?param=1&another=2', [['another', '3']]);
expect(url).toEqual('test?param=1&another=3');
expect(url).toEqual('test?param=1&another=3');

url = CMS.API.Helpers.makeURL('test?param=1&another=2', [['another', '3'], ['param', '4']]);
expect(url).toEqual('test?another=3&param=4');
expect(url).toEqual('test?another=3&param=4');
});

it('understands hashes in the url', function() {
var url;

url = CMS.API.Helpers.makeURL('test#hash', [['param', '1'], ['another', '2']]);
expect(url).toEqual('test?param=1&another=2#hash');
expect(url).toEqual('test?param=1&another=2#hash');

url = CMS.API.Helpers.makeURL('test#hash#with#hash', [['param', '1'], ['another', '2']]);
expect(url).toEqual('test?param=1&another=2#hash#with#hash');
expect(url).toEqual('test?param=1&another=2#hash#with#hash');

url = CMS.API.Helpers.makeURL('test#', [['param', '1'], ['another', '2']]);
expect(url).toEqual('test?param=1&another=2');
expect(url).toEqual('test?param=1&another=2');

url = CMS.API.Helpers.makeURL('test#hash&stuff', [['param', '1'], ['another', '2']]);
expect(url).toEqual('test?param=1&another=2#hash&stuff');
expect(url).toEqual('test?param=1&another=2#hash&stuff');

url = CMS.API.Helpers.makeURL('test#hash&stuff', []);
expect(url).toEqual('test#hash&stuff');
Expand Down
2 changes: 1 addition & 1 deletion cms/tests/frontend/unit/cms.structureboard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,7 @@ describe('CMS.StructureBoard', function() {

expect($.ajax).toHaveBeenCalledWith({
url: jasmine.stringMatching(
/TOOLBAR_URL\?obj_id=100&obj_type=cms.page&cms_path=%2Fcontext.html.*/
/TOOLBAR_URL\?obj_id=100&obj_type=cms.page&cms_path=%2Fcontext.html.*/
)
});
});
Expand Down
0