Skip to content

Commit

Permalink
optimeraRtd: hotfix for handling score file URIs (#11520)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarbartopti authored and Marcin Komorski committed May 21, 2024
1 parent 4af2afb commit a20163d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion modules/optimeraRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions test/spec/modules/optimeraRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand All @@ -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');
});
});

Expand Down

0 comments on commit a20163d

Please sign in to comment.