From ca0eb3476d0f7add3206dd78a193aaa9ed433a41 Mon Sep 17 00:00:00 2001 From: webmiraclepro Date: Wed, 14 Mar 2018 02:17:42 +0800 Subject: [PATCH] Loosen up the vimeo URL pattern Fixes https://github.com/CookPete/react-player/issues/349 Closes https://github.com/CookPete/react-player/pull/348 --- src/players/Vimeo.js | 17 +++++++++-------- test/specs/canPlay.js | 1 + 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/players/Vimeo.js b/src/players/Vimeo.js index e2597d6..024aa31 100644 --- a/src/players/Vimeo.js +++ b/src/players/Vimeo.js @@ -5,7 +5,7 @@ import createSinglePlayer from '../singlePlayer' const SDK_URL = 'https://player.vimeo.com/api/player.js' const SDK_GLOBAL = 'Vimeo' -const MATCH_URL = /(?:www\.|player\.)?vimeo.com\/(?:(?:channels|ondemand)\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/ +const MATCH_URL = /vimeo.com\// export class Vimeo extends Component { static displayName = 'Vimeo' @@ -15,13 +15,8 @@ export class Vimeo extends Component { duration = null currentTime = null secondsLoaded = null - load (url, isReady) { - const id = url.match(MATCH_URL)[3] + load (url) { this.duration = null - if (isReady) { - this.player.loadVideo(id).catch(this.props.onError) - return - } getSDK(SDK_URL, SDK_GLOBAL).then(Vimeo => { if (!this.container) return this.player = new Vimeo.Player(this.container, { @@ -88,7 +83,13 @@ export class Vimeo extends Component { backgroundColor: 'black', ...this.props.style } - return
+ return ( +
+ ) } } diff --git a/test/specs/canPlay.js b/test/specs/canPlay.js index 837f519..972ba7b 100644 --- a/test/specs/canPlay.js +++ b/test/specs/canPlay.js @@ -56,6 +56,7 @@ describe('canPlay', () => { expect(Vimeo.canPlay('https://vimeo.com/groups/motion/videos/73234721')).to.be.true expect(Vimeo.canPlay('https://vimeo.com/album/3953264/video/166790294')).to.be.true expect(Vimeo.canPlay('https://player.vimeo.com/video/40004005')).to.be.true + expect(Vimeo.canPlay('https://vimeo.com/yannickcerrutti/annecydroneinmotion')).to.be.true }) it('knows what it can\'t play', () => {