UNPKG

better-video-embeds

Version:

Pass in a url that should be a video embed link...and get back a properly formated embed link. (Works for YouTube, Vimeo, Wistia and more!)

3 lines (2 loc) 840 B
"use strict";exports.default=function(e,t){if(!e)return"";var i=/vimeo.*\/(\d+)/i.exec(e);if(i&&i[1])return"https://player.vimeo.com/video/"+i[1];if(e.includes("dailymotion")||e.includes("dai.ly"))return function(e){var t=/(?:dailymotion\.com(?:\/video|\/hub)|dai\.ly)\/([0-9a-z]+)(?:[\-_0-9a-zA-Z]+#video=([a-z0-9]+))?/g.exec(e);return t&&t[1]&&"https://www.dailymotion.com/embed/video/"+t[1]||e}(e);if(e.includes("wistia"))return function(e){var t=e.split("/"),i=t[t.length-1];return i?"https://fast.wistia.net/embed/iframe/"+i:e}(e);var n=e.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/);return n&&11===n[2].length?"https://www.youtube.com/embed/"+n[2]+(t&&t.includeModestYouTubeBranding?"?rel=0&showinfo=0&modestbranding=0&enablejsapi=1":""):e}; //# sourceMappingURL=better-video-embeds.cjs.production.min.js.map