Use encodeURIComponent instead of encodeURI

We should use encodeURIComponent instead of encodeURI when encoding part of uri like querystring. encodeURI does not encode `+` sign. For example a query string parameter like `scope=user_id+profile+email` is not encoded by `encodeURI` which results in invalid url on select multiple enterprise page.

Fixed broken test
This commit is contained in:
zia.fazal@arbisoft.com
2020-02-24 12:40:12 +05:00
parent babd15259e
commit eeb390862c
2 changed files with 2 additions and 2 deletions

View File

@@ -9,7 +9,7 @@ define([
describe('MultipleEnterpriseInterface', function() {
var LEARNER_URL = '/enterprise/api/v1/enterprise-learner/?username=test-learner',
NEXT_URL = '/dashboard',
REDIRECT_URL = '/enterprise/select/active/?success_url=/dashboard';
REDIRECT_URL = '/enterprise/select/active/?success_url=%2Fdashboard';
beforeEach(function() {
// Mock the redirect call

View File

@@ -18,7 +18,7 @@
* @param {string} nextUrl The URL to redirect to after multiple enterprise selection.
*/
check: function(nextUrl) {
var redirectUrl = this.urls.multipleEnterpriseUrl + encodeURI(nextUrl);
var redirectUrl = this.urls.multipleEnterpriseUrl + encodeURIComponent(nextUrl);
var username = Utils.userFromEdxUserCookie().username;
var next = nextUrl || '/';
$.ajax({