Skip to content

Commit

Permalink
Actually support full URLs to videos, fixes #198
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Oct 17, 2022
1 parent 941b68b commit e7128b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ class Vimeo extends React.Component {
* @private
*/
getInitialOptions() {
const { video } = this.props;
const videoType = /^https?:/i.test(video) ? 'url' : 'id';
/* eslint-disable react/destructuring-assignment */
return {
id: this.props.video,
[videoType]: video,
width: this.props.width,
height: this.props.height,
autopause: this.props.autopause,
Expand Down
6 changes: 6 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ describe('Vimeo', () => {
expect(onReady.calls[0].arguments[0]).toBe(playerMock);
});

it('should use `url` prop for full vimeo URLs', async () => {
const { sdkMock } = render({ video: 'https://vimeo.com/179290396' });
expect(sdkMock).toHaveBeenCalled();
expect(sdkMock.calls[0].arguments[1]).toMatch({ url: 'https://vimeo.com/179290396' });
});

it('should all onError when `ready()` fails', async () => {
const onError = createSpy();
const { sdkMock } = render({
Expand Down

0 comments on commit e7128b6

Please sign in to comment.