Skip to content

Commit

Permalink
Support sharing of unlisted Vimeo videos
Browse files Browse the repository at this point in the history
  • Loading branch information
jaylinski committed Jan 31, 2021
1 parent a5de11d commit 20b2bf3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/modules/plugins/Vimeo.js
Expand Up @@ -16,7 +16,11 @@ class Vimeo extends WebPlugin {
}

getVideoId(url) {
return url.pathname.split('/').pop();
return url.pathname
.replace(/^\/+/, '')
.split('/')
.filter((n) => Number.parseInt(n, 10))
.join(':');
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/modules/plugins/Vimeo.test.js
Expand Up @@ -17,6 +17,14 @@ test('Generates a plugin path from a channel URL', async () => {
expect(pluginPath).toBe('plugin://plugin.video.vimeo/play/?video_id=388640017');
});

test('Generates a plugin path from an unlisted video URL', async () => {
const vimeo = new Vimeo();
const url = new URL('https://vimeo.com/12345/6789');
const pluginPath = await vimeo.getPluginPath({ url });

expect(pluginPath).toBe('plugin://plugin.video.vimeo/play/?video_id=12345:6789');
});

test('Generates a plugin path from a URL with tracking params', async () => {
const vimeo = new Vimeo();
const url = new URL('https://vimeo.com/1234567?foo=bar&utm=vimeo');
Expand Down

0 comments on commit 20b2bf3

Please sign in to comment.