File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -320,7 +320,19 @@ export function finishView (view) {
320
320
imgPlayiframe ( this , '//player.vimeo.com/video/' )
321
321
} )
322
322
. 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 ) {
324
336
const thumbnailSrc = data [ 0 ] . thumbnail_large
325
337
const image = `<img src="${ thumbnailSrc } " />`
326
338
$ ( value ) . prepend ( image )
You can’t perform that action at this time.
0 commit comments