mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Fix #2181 regexp assertion compatibility with older browsers
This commit is contained in:
parent
62f04a1e02
commit
31253cdb43
1 changed files with 8 additions and 3 deletions
|
|
@ -54,9 +54,14 @@
|
|||
|
||||
// Convert YouTube links.
|
||||
var convertYouTube = function(str) {
|
||||
var regexp = /(?<!src=")https?:\/\/(www\.youtube(?:-nocookie)?\.com\/(?:watch\?v=|v\/|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]+)\S*/g;
|
||||
var embed = '<iframe width="560" height="315" src="https://www.youtube.com/embed/$2" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe><p></p>';
|
||||
return String(str).replace(regexp, embed);
|
||||
var regexp = /(src=")?https?:\/\/(www\.youtube(?:-nocookie)?\.com\/(?:watch\?v=|v\/|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]+)\S*/g;
|
||||
return String(str).replace(regexp, function(match, p1, p2, p3) {
|
||||
if (p1 === 'src="') {
|
||||
return match;
|
||||
} else {
|
||||
return '<iframe width="560" height="315" src="https://www.youtube.com/embed/' + p3 + '" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe><p></p>';
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Page load event handler.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue