HFP-1905 Fix finding copyright edge case bug

pull/52/head
Oliver Tacke 2018-06-01 15:45:09 +02:00
parent a30a93e62e
commit 8f45ea4d79
1 changed files with 7 additions and 3 deletions

View File

@ -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