From 1575e0102e55a091289a499035dba567daf529f7 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 24 Jun 2014 14:41:35 +0200 Subject: [PATCH] Fixed embed script. --- js/h5p.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/js/h5p.js b/js/h5p.js index 46a6b6b..f0860e5 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -279,7 +279,11 @@ H5P.fullScreen = function ($element, instance, exitCallback, body) { * Id of the content requesting a path */ H5P.getPath = function (path, contentId) { - if (path.substr(0, 7) === 'http://' || path.substr(0, 8) === 'https://') { + var hasProtocol = function (path) { + return path.match(/^[a-z0-9]+:\/\//i); + }; + + if (hasProtocol(path)) { return path; } @@ -293,7 +297,11 @@ H5P.getPath = function (path, contentId) { return; } - return window.parent.location.protocol + "//" + window.parent.location.host + prefix + '/' + path; + if (!hasProtocol(prefix)) { + prefix = window.parent.location.protocol + "//" + window.parent.location.host + prefix; + } + + return prefix + '/' + path; }; /**