Skip to content

Commit

Permalink
feat: set iframe as a default provider for valid urls
Browse files Browse the repository at this point in the history
  • Loading branch information
ala-n committed Mar 10, 2021
1 parent a7a40d8 commit f320d88
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/modules/esl-media/providers/iframe-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ export class IframeBasicProvider extends BaseProvider {
private _state: PlayerStates = PlayerStates.UNINITIALIZED;
protected _el: HTMLIFrameElement;

static parseUrl(url: string) {
try {
if (!url) return null;
const {protocol} = new URL(url);
if (protocol !== 'http:' && protocol !== 'https:') return null;
return {mediaSrc: url};
} catch {
return null;
}
}

protected buildIframe() {
const el = document.createElement('iframe');
el.id = 'esl-media-iframe-' + generateUId();
Expand Down

0 comments on commit f320d88

Please sign in to comment.