Skip to content

Commit

Permalink
Merge 73eea09 into ad0d7e0
Browse files Browse the repository at this point in the history
  • Loading branch information
lqez committed Dec 13, 2018
2 parents ad0d7e0 + 73eea09 commit 453c6e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/js/base/module/VideoDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ export default class VideoDialog {
const webmRegExp = /^.+.(webm)$/;
const webmMatch = url.match(webmRegExp);

const fbRegExp = /(?:www\.|\/\/)facebook\.com\/([^\/]+)\/videos\/([0-9]+)/;
const fbMatch = url.match(fbRegExp);

let $video;
if (ytMatch && ytMatch[1].length === 11) {
const youtubeId = ytMatch[1];
Expand Down Expand Up @@ -139,6 +142,13 @@ export default class VideoDialog {
$video = $('<video controls>')
.attr('src', url)
.attr('width', '640').attr('height', '360');
} else if (fbMatch && fbMatch[0].length) {
$video = $('<iframe>')
.attr('frameborder', 0)
.attr('src', 'https://www.facebook.com/plugins/video.php?href=' + encodeURIComponent(fbMatch[0]) + '&show_text=0&width=560')
.attr('width', '560').attr('height', '301')
.attr('scrolling', 'no')
.attr('allowtransparency', 'true');
} else {
// this is not a known video link. Now what, Cat? Now what?
return false;
Expand Down
3 changes: 3 additions & 0 deletions test/unit/base/module/VideoDialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ describe('VideoDialog', () => {
'//v.qq.com/iframe/player.html?vid=f0196y2b2cx&amp;auto=0');
expectUrl('http://v.qq.com/x/page/p0330y279lm.html',
'//v.qq.com/iframe/player.html?vid=p0330y279lm&amp;auto=0');
// Facebook
expectUrl('https://www.facebook.com/Engineering/videos/631826881803/',
'//www.facebook.com/plugins/video.php?href=www.facebook.com%2FEngineering%2Fvideos%2F631826881803');
});

it('should be embedded start parameter when insert YouTube video with t', () => {
Expand Down

0 comments on commit 453c6e5

Please sign in to comment.