Skip to content

Commit 3922cc8

Browse files
Merge pull request #41 from EkoLabs/overriding-host-param
Added the ability to override the URL's host via options.
2 parents a5dbf54 + 73d93eb commit 3922cc8

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

src/lib/ekoEmbed/EkoEmbedDeliveryBase.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ class EkoEmbedDeliveryBase {
2222
};
2323
}
2424

25+
getDeliveryUrl(embedParams, options) {
26+
const host = options.host ? `${options.host}` : `${options.env || ''}embed.eko.com`;
27+
return `https://${host}${this.embedpath}?${stringifyQueryParams(embedParams)}`;
28+
}
2529

2630
load(id, options) {
2731
let embedParams = {
@@ -53,7 +57,7 @@ class EkoEmbedDeliveryBase {
5357
// Finally, let's set the iframe's src to begin loading the project
5458
this.iframe.setAttribute(
5559
'src',
56-
`https://${options.env || ''}embed.eko.com${this.embedpath}?${stringifyQueryParams(embedParams)}`
60+
this.getDeliveryUrl(embedParams, options)
5761
);
5862
}
5963

@@ -70,6 +74,7 @@ class EkoEmbedDeliveryBase {
7074

7175
this.iframe.contentWindow.postMessage(action, '*');
7276
}
77+
7378
on(eventName, callback) {
7479
this.eventEmitter.on(eventName, callback);
7580
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* eslint-disable no-undef */
2+
/* eslint-disable new-cap */
3+
/* eslint-disable no-magic-numbers */
4+
const puppeteer = require('puppeteer');
5+
const testingInstanceId = '42rvvp6tpn';
6+
7+
let browser;
8+
beforeAll(async() => {
9+
browser = await puppeteer.launch({
10+
headless: true,
11+
args: ['--disable-features=site-per-process']
12+
});
13+
}, 10000);
14+
15+
afterAll(async() => {
16+
await browser.close();
17+
}, 15000);
18+
19+
jest.setTimeout(999999);
20+
21+
describe('ekoPlayer.load()', () => {
22+
it(`ekoPlayer.load(id, { host: 'directembed.eko.com' }))
23+
check host override `, async() => {
24+
const page = await browser.newPage();
25+
await page.goto(`file://${__dirname}/../app.html`);
26+
27+
await page.evaluate((instanceId) => {
28+
let ekoPlayer = new EkoPlayer('#ekoPlayerEl', '3.0');
29+
ekoPlayer.load(instanceId, {
30+
iframeAttributes: { id: 'testFrame' },
31+
host: 'directembed.eko.com'
32+
});
33+
}, testingInstanceId);
34+
35+
// Check host
36+
const host = await page.evaluate(() => {
37+
const iframeSrc = document.querySelector('iframe').getAttribute('src');
38+
const iframeURL = new URL(iframeSrc);
39+
return iframeURL.host;
40+
});
41+
42+
expect(host).toBeDefined();
43+
expect(host).toEqual('directembed.eko.com');
44+
});
45+
});

test/integration/ekoDelivery/v3.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-disable new-cap */
33
/* eslint-disable no-magic-numbers */
44
const puppeteer = require('puppeteer');
5-
const testingInstanceId = 'IlA4fs022o';
5+
const testingInstanceId = '42rvvp6tpn';
66

77
let browser;
88
beforeAll(async() => {

0 commit comments

Comments
 (0)