Skip to content

Commit

Permalink
Loosen up the vimeo URL pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
webmiraclepro committed Mar 13, 2018
1 parent c52eb97 commit ca0eb34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/players/Vimeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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, {
Expand Down Expand Up @@ -88,7 +83,13 @@ export class Vimeo extends Component {
backgroundColor: 'black',
...this.props.style
}
return <div style={style} ref={this.ref} />
return (
<div
key={this.props.url}
ref={this.ref}
style={style}
/>
)
}
}

Expand Down
1 change: 1 addition & 0 deletions test/specs/canPlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit ca0eb34

Please sign in to comment.