Skip to content

Commit

Permalink
fix: fix youtube url regexp, typo in error and mock formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ala-n committed Jan 18, 2021
1 parent d19ef79 commit 1da03bd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/modules/esl-media/core/esl-media-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ESLMediaProviderRegistry extends Observable {

/** Register provider */
public register(provider: ProviderType) {
if (!provider.providerName) throw new Error('Provider should have name');
if (!provider.providerName) throw new Error('Provider should have a name');
this.providersMap.set(provider.providerName, provider);
this.fire(provider.providerName, provider);
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/esl-media/providers/youtube-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const DEFAULT_ASPECT_RATIO = 16 / 9;
@BaseProvider.register
export class YouTubeProvider extends BaseProvider {
static readonly providerName = 'youtube';
static readonly idRegexp = /(?:v\/|v=|vi=|vi\/|e\/|embed\/|user\/.*\/u\/\d+\/)([_0-9a-zA-Z-]+)/;
static readonly providerRegexp = /(?:http(?:s)?:\/\/)?(?:www\.)?(?:youtu\.be|youtube(-nocookie)?\.com)/;
static readonly idRegexp = /(?:v\/|v=|vi=|vi\/|e\/|embed\/|user\/.*\/u\/\d+\/)([_0-9a-zA-Z-]+)/i;
static readonly providerRegexp = /^\s*(?:http(?:s)?:\/\/)?(?:www\.)?(?:youtu\.be|youtube(-nocookie)?\.com)/i;

protected _el: HTMLDivElement | HTMLIFrameElement;
protected _api: YT.Player;
Expand Down
39 changes: 17 additions & 22 deletions src/modules/esl-media/test/base-provider.mock.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
import {BaseProvider, PlayerStates} from '../core/esl-media-provider';

export class BaseProviderMock extends BaseProvider {
public bind(): void {
}
public bind(): void {}

public get duration(): number {
return 0;
}
public get duration(): number {
return 0;
}

public get currentTime(): number {
return 0;
}
public get currentTime(): number {
return 0;
}

public get defaultAspectRatio(): number {
return 0;
}
public get defaultAspectRatio(): number {
return 0;
}

protected pause(): void | Promise<any> {
}
protected pause(): void | Promise<any> {}

protected play(): void | Promise<any> {
}
protected play(): void | Promise<any> {}

protected stop(): void | Promise<any> {
}
protected stop(): void | Promise<any> {}

protected seekTo(pos?: number): void | Promise<any> {
}
protected seekTo(pos?: number): void | Promise<any> {}

public get state() {
return PlayerStates.UNINITIALIZED;
}
public get state() {
return PlayerStates.UNINITIALIZED;
}
}

0 comments on commit 1da03bd

Please sign in to comment.