Merge pull request #111 from GeorgeDeac/kasen/core

Support for short youtube url in linkify
This commit is contained in:
kasenvr 2020-01-28 16:15:48 -05:00 committed by GitHub
commit 486c7bde5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -183,9 +183,9 @@
case protocol === "hifi":
elContent = elContent.replace(this, "<br/><a href=\"javascript:gotoHiFi('" + this + "');\">" + this + "</a>");
break;
case !!this.match(/^(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?(?=.*v=((\w|-){11}))(?:\S+)?$/):
case !!this.match(/(https?:\/\/)?(www\.)?(youtube\.com\/watch\?v=|youtu\.be\/)([^& \n<]+)(?:[^ \n<]+)?/g):
var youtubeMatch = this.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/);
if (youtubeMatch && youtubeMatch[2].length == 11 && this.match(/^(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?(?=.*v=((\w|-){11}))(?:\S+)?$/)) {
if (youtubeMatch && youtubeMatch[2].length == 11) {
elContent = "<br/><iframe class=\"z-depth-2\" width='420' height='236' src='https://www.youtube.com/embed/" + youtubeMatch[2] + "' frameborder='0'></iframe><br/><a href=\"javascript:gotoURL('" + this + "');\">" + this + "</a>";
break;
}
@ -468,4 +468,4 @@
</body>
</html>
</html>