Skip to content

Commit

Permalink
support *.videoji.hk domains as vimeo domains
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronm67 committed Apr 16, 2024
1 parent 8f37159 commit 73e6a8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function isInteger(value) {
* @return {boolean}
*/
export function isVimeoUrl(url) {
return (/^(https?:)?\/\/((player|www)\.)?vimeo\.com(?=$|\/)/).test(url);
return (/^(https?:)?\/\/((((player|www)\.)?vimeo\.com)|((player\.)?[a-zA-Z0-9\-]+\.videoji.hk))(?=$|\/)/).test(url);

Check failure on line 61 in src/lib/functions.js

View workflow job for this annotation

GitHub Actions / run

Unnecessary escape character: \-
}

/**
Expand All @@ -68,7 +68,7 @@ export function isVimeoUrl(url) {
* @return {boolean}
*/
export function isVimeoEmbed(url) {
const expr = /^https:\/\/player\.vimeo\.com\/video\/\d+/;
const expr = /^https:\/\/player\.((vimeo\.com)|([a-zA-Z0-9\-]+\.videoji\.hk))\/video\/\d+/;

Check failure on line 71 in src/lib/functions.js

View workflow job for this annotation

GitHub Actions / run

Unnecessary escape character: \-
return expr.test(url);
}

Expand Down
7 changes: 7 additions & 0 deletions test/functions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ test('isVimeoUrl identifies *.vimeo.com only', (t) => {
t.true(isVimeoUrl('https://www.vimeo.com') === true);
t.true(isVimeoUrl('//www.vimeo.com') === true);
t.true(isVimeoUrl('http://player.vimeo.com') === true);
t.true(isVimeoUrl('http://player.vimeo.com') === true);
t.true(isVimeoUrl('http://player.stuff.videoji.hk') === true);
t.true(isVimeoUrl('http://player.stuff.videoji.hk/video/12345') === true);
t.true(isVimeoUrl('http://player.stuff.videoji.hk/video/12345?h=a1b2c3d4') === true);
t.true(isVimeoUrl('http://vimeo.videoji.hk') === true);
t.true(isVimeoUrl('http://videoji.hk') === false);
t.true(isVimeoUrl('//player.vimeo.com') === true);
t.true(isVimeoUrl('https://player.vimeo.com') === true);
t.true(isVimeoUrl('https://notvimeo.com') === false);
Expand All @@ -56,6 +62,7 @@ test('isVimeoEmbed identifies Vimeo embeds only', (t) => {
t.true(isVimeoEmbed('https://player.vimeo.com/video/76979871?h=8272103f6e') === true);
t.true(isVimeoEmbed('https://player.vimeo.com/video/76979871') === true);
t.true(isVimeoEmbed('http://player.vimeo.com/video/76979871?h=8272103f6e') === false);
t.true(isVimeoEmbed('http://player.stuff.videoji.hk/video/76979871?h=8272103f6e') === false);
t.true(isVimeoEmbed('http2://not-vimeo.com/video/76979871') === false);
});

Expand Down

0 comments on commit 73e6a8d

Please sign in to comment.