Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function renderCaption(cue) {
if (captionContainer) {
const finalCue = document.createElement('div');
captionContainer.appendChild(finalCue);
previousISDState = renderHTML(cue.isd, finalCue, function (uri) {
const imsc1ImgUrnTester = /^(urn:)(mpeg:[a-z0-9][a-z0-9-]{0,31}:)(subs:)([0-9]+)$/;
const smpteImgUrnTester = /^#(.*)$/;
if (imsc1ImgUrnTester.test(uri)) {
const match = imsc1ImgUrnTester.exec(uri);
const imageId = parseInt(match[4], 10) - 1;
const imageData = btoa(cue.images[imageId]);
const dataUrl = 'data:image/png;base64,' + imageData;
return dataUrl;
} else if (smpteImgUrnTester.test(uri)) {
const match = smpteImgUrnTester.exec(uri);
const imageId = match[1];
const dataUrl = 'data:image/png;base64,' + cue.embeddedImages[imageId];
return dataUrl;
} else {
return null;
}