diff --git a/modules/optimeraRtdProvider.js b/modules/optimeraRtdProvider.js index bd564e3a260..71cd2a3b79b 100644 --- a/modules/optimeraRtdProvider.js +++ b/modules/optimeraRtdProvider.js @@ -187,7 +187,11 @@ export function setScoresURL() { if (apiVersion === 'v1') { newScoresURL = `${baseUrl}api/products/scores?c=${clientID}&h=${optimeraHost}&p=${optimeraPathName}&s=${device}`; } else { - newScoresURL = `${baseUrl}${clientID}/${optimeraHost}${optimeraPathName}.js`; + let encoded = encodeURIComponent(`${optimeraHost}${optimeraPathName}`) + .replaceAll('%2F', '/') + .replaceAll('%20', '+'); + + newScoresURL = `${baseUrl}${clientID}/${encoded}.js`; } if (scoresURL !== newScoresURL) { diff --git a/test/spec/modules/optimeraRtdProvider_spec.js b/test/spec/modules/optimeraRtdProvider_spec.js index 8a9f000bbb9..e1d962d306c 100644 --- a/test/spec/modules/optimeraRtdProvider_spec.js +++ b/test/spec/modules/optimeraRtdProvider_spec.js @@ -37,7 +37,7 @@ describe('Optimera RTD score file URL is properly set for v0', () => { optimeraRTD.init(conf.dataProviders[0]); optimeraRTD.setScores(); expect(optimeraRTD.apiVersion).to.equal('v0'); - expect(optimeraRTD.scoresURL).to.equal('https://dyv1bugovvq1g.cloudfront.net/9999/localhost:9876/context.html.js'); + expect(optimeraRTD.scoresURL).to.equal('https://dyv1bugovvq1g.cloudfront.net/9999/localhost%3A9876/context.html.js'); }); it('should properly set the score file URL without apiVersion set', () => { @@ -54,7 +54,7 @@ describe('Optimera RTD score file URL is properly set for v0', () => { optimeraRTD.init(conf.dataProviders[0]); optimeraRTD.setScores(); expect(optimeraRTD.apiVersion).to.equal('v0'); - expect(optimeraRTD.scoresURL).to.equal('https://dyv1bugovvq1g.cloudfront.net/9999/localhost:9876/context.html.js'); + expect(optimeraRTD.scoresURL).to.equal('https://dyv1bugovvq1g.cloudfront.net/9999/localhost%3A9876/context.html.js'); }); it('should properly set the score file URL with an api version other than v0 or v1', () => { @@ -71,7 +71,7 @@ describe('Optimera RTD score file URL is properly set for v0', () => { }; optimeraRTD.init(conf.dataProviders[0]); optimeraRTD.setScores(); - expect(optimeraRTD.scoresURL).to.equal('https://dyv1bugovvq1g.cloudfront.net/9999/localhost:9876/context.html.js'); + expect(optimeraRTD.scoresURL).to.equal('https://dyv1bugovvq1g.cloudfront.net/9999/localhost%3A9876/context.html.js'); }); });