File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -320,7 +320,19 @@ export function finishView (view) {
320320 imgPlayiframe ( this , '//player.vimeo.com/video/' )
321321 } )
322322 . each ( ( key , value ) => {
323- jsonp ( `//vimeo.com/api/v2/video/${ $ ( value ) . attr ( 'data-videoid' ) } .json` , function ( data ) {
323+ const videoId = $ ( value ) . attr ( 'data-videoid' )
324+ let urlForJsonp = ''
325+ try {
326+ const url = new URL ( `https://vimeo.com/api/v2/video/${ videoId } .json` )
327+ if ( ! url . pathname . startsWith ( '/api/v2/video/' ) ) {
328+ throw new Error ( `Invalid vimeo video id: ${ videoId } ` )
329+ }
330+ urlForJsonp = `//${ url . origin } ${ url . pathname } `
331+ } catch ( err ) {
332+ console . error ( err )
333+ return
334+ }
335+ jsonp ( urlForJsonp , function ( data ) {
324336 const thumbnailSrc = data [ 0 ] . thumbnail_large
325337 const image = `<img src="${ thumbnailSrc } " />`
326338 $ ( value ) . prepend ( image )
You can’t perform that action at this time.
0 commit comments