Skip to content
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

optimera Rtd Module : hotfix for handling score file URIs #11520

Merged
merged 1 commit into from
May 21, 2024
Merged
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
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