From 8f45ea4d7920b1c85189fc3305db44247b749c7e Mon Sep 17 00:00:00 2001 From: Oliver Tacke Date: Fri, 1 Jun 2018 15:45:09 +0200 Subject: [PATCH] HFP-1905 Fix finding copyright edge case bug --- js/h5p.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/h5p.js b/js/h5p.js index 390efe4..ea21c78 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -1024,7 +1024,7 @@ H5P.getCopyrights = function (instance, parameters, contentId, metadata) { * Used to insert thumbnails for images. */ H5P.findCopyrights = function (info, parameters, contentId) { - var lastContentTypeName = undefined; + var lastContentTypeName; // Cycle through parameters for (var field in parameters) { if (!parameters.hasOwnProperty(field)) { @@ -1045,8 +1045,12 @@ H5P.findCopyrights = function (info, parameters, contentId) { var value = parameters[field]; - // TODO: Get the real name of the content type - lastContentTypeName = (value.library) ? value.library.split(' ')[0] : lastContentTypeName; + if (value.library && typeof value.library === 'string') { + lastContentTypeName = value.library.split(' ')[0]; + } + else if (value.library && typeof value.library === 'object') { + lastContentTypeName = (value.library.library && typeof value.library.library === 'string') ? value.library.library.split(' ')[0] : lastContentTypeName; + } if (value instanceof Array) { // Cycle through array